AnsweredAssumed Answered

Restarting Loop on no record found

Question asked by moodog on Dec 29, 2017
Latest reply on Dec 30, 2017 by moodog

I have a multi nested loop... Basically I open Customer table look for Default billing method and get a list of those customers. There are always Default billing customers so Im not worried about that. Ive put what Im doing in almost plain English and then I pasted the portion of the actual script. If I cant get this figured out I guess I could try to break it up in to smaller scripts but I figure there has to be away to do this Im just fried. Appreciate any help..

 

I start a loop at first record and get customer ID as variable.

I open new window - work orders - and perform find for Customer ID, Work Order Complete & invoice Null.

I set another loop

Get Variables I need

Open new window - Invoice header

New Record Request

Add Variables to new record

exit on last record

end loop

then New loop

that gets all the detail lines of the invoice.

 

My script works as expected if there are work orders.

When there are no work orders is the problem.

 

I need to close the window and go to next customer basically stop where I am in the script and go back.

 

 

New Window [ Style: Document; Name: "Process Invoice"; Using layout: “Customer Data Table” (CustomerTBL); Close: Yes; Minimize:

Yes; Maximize: Yes; Resize: Yes; Menu Bar: Yes; Dim parent window: No; Toolbars: Yes ]

Show All Records

Enter Find Mode [ ]

Set Field [ CustomerTBL::BillingMethod; "Default" ]

Perform Find [ ]

Sort Records [ Keep records in sorted order; Specified Sort Order: CustomerTBL::Customer ID; ascending ] [ Restore; No dialog ]

Go to Record/Request/Page

[ First ]

Loop

Set Variable [ $Customer; Value:CustomerTBL::Customer ID ]

New Window [ Style: Document; Name: "Process Default Invoice"; Using layout: “WorkOrder - Data” (WorkOrder); Close: Yes; Minimize: Yes; Maximize: Yes; Resize: Yes; Menu Bar: Yes; Dim parent window: No; Toolbars: Yes ]

Enter Find Mode [ ]

Set Error Capture [ On ]

Set Field [ WorkOrder::Customer; $Customer ]

Set Field [ WorkOrder::Invoice Date; "=" ]

Set Field [ WorkOrder::Status; "==Complete" ]

Perform Find [ ]

If Get(FoundCount) = 0

Close Window - This should leave me at the customer list, I will need to go to next record and exit on last.

Else

End If

(Maybe Im thinking to much but I can not get this work, and I can't exit loop because I want the next customer, I just need to restart at next customer. I may have a list of 10 customers and only a few of them have WorkOrders ready for Invoice...)

 

Go to Record/Request/Page

[ First ]

Loop

#get header from Work order

Set Variable [ $CustID; Value:WorkOrder::Customer ]
Set Variable [ $WONumber; Value:WorkOrder::PIC_WONumber ] Set Variable [ $WOKey; Value:WorkOrder::k_wokey ]
Set Variable [ $WONotes; Value:WorkOrder::Notes ]
Set Variable [ $BookingNumber; Value:WorkOrder::BookingNumber ] Set Variable [ $PULocation; Value:WorkOrder::PULocation ]
Set Variable [ $DelLocation; Value:WorkOrder::DeliverTo ]
Set Variable [ $RetLocation; Value:WorkOrder::ReturnTo ]
Etc..

Etc..

Etc...

Etc...

 

Thanks,

Rich

 

 

Outcomes