4 Replies Latest reply on Mar 12, 2014 1:36 PM by willrollo

    loop not working properly on print many records

      Title

      loop not working properly on print many records

      Post

           I have a print script that finds a group of records and then prints the all one after the other. However, the loop seems to end early, with one record not printed... I am not sure why so should be grateful for any advice... the script is below with the loop in red.. In case you are wondering why there are two print script lines, it is because   copy needs to be printed and this is on another printer...

           Thank you

             
      •           Allow User Abort [ Off ]
      •      
      •           Set Error Capture [ On ]
      •      
      •           Set Variable [ $Q; Value:INVOICE DETAILS::ID_Customer_Billing_fk ]
      •      
      •           Set Field [ INVOICE DETAILS::Comments Quotation; TextSize( TextFont( (INVOICE DETAILS::Comments Quotation); "Times New Roman" ) ; 14) ]
      •      
      •           Commit Records/Requests [ Skip data entry validation; No dialog ]
      •      
      •           If [ not IsEmpty(INVOICE DETAILS::Printed Quote) ]
      •      
      •           Show Custom Dialog [ Title: "Warning"; Message: "Reprint this quote?"; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
      •      
      •           If [ Get(LastMessageChoice) = 1 ]
      •      
      •           Perform Script [ “RePrint Quote” ]
      •      
      •           Exit Script [ ]
      •      
      •           Else
      •      
      •           Exit Script [ ]
      •      
      •           End If
      •      
      •           End If
      •      
      •           Loop
      •      
      •           Show Custom Dialog [ Title: "Message"; Message: "Do you want to print this quote?"; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
      •      
      •           Go to Record/Request/Page [ First ]
      •      
      •           If [ Get(LastMessageChoice) = 1 ]
      •      
      •           Show Custom Dialog [ Title: "Reminder"; Message: "Have you (un)checked the boxes to include the measuring/sign order form"; Default Button: “Yes”, Commit: “Yes”; Button 2: “No/Cancel”, Commit: “No” ]
      •      
      •           If [ Get(LastMessageChoice) = 2 ]
      •      
      •           Go to Field [ INVOICE DETAILS::Text_Signed Form_deposit ]
      •      
      •           Exit Script [ ]
      •      
      •           End If
      •      
      •           Commit Records/Requests [ Skip data entry validation; No dialog ]
      •      
      •           Set Variable [ $ID; Value:INVOICE DETAILS::ID_Invoice_pk ]
      •      
      •           Freeze Window
      •      
      •           Go to Related Record [ From table: “invoicedetails_INVOICEITEM”; Using layout: “Quote Print” (INVOICEITEMS) ] [ Show only related records ]
      •      
      •           Print Setup [ Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
      •      
      •           Print [ Records being browsed; All Pages; Orientation: Landscape; Paper size: 1.41" x 3.49" ] [ Restore: Letters Printer; No dialog ]
      •      
      •           Print Setup [ Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
      •      
      •           Print [ Records being browsed; All Pages; Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore: B&W Copy printer; No dialog ]
      •      
      •           If [ Get (LastError) = 0 ]
      •      
      •           #Set Print TimeStamp
      •      
      •           Enter Browse Mode
      •      
      •           Go to Layout [ “Quote” (INVOICE DETAILS) ]
      •      
      •           Set Field [ INVOICE DETAILS::TimeStamp_Printed Quote; Get (CurrentTimeStamp) ]
      •      
      •           Set Field [ INVOICE DETAILS::Status Quote; "Posted" & " " & Get (CurrentDate) ]
      •      
      •           Set Field [ INVOICE DETAILS::Printed Quote; "Yes" ]
      •      
      •           Set Field [ invoicedetails_CUSTOMERS__billing::Follow Up Actions Box; "Quote Sent" ]
      •      
      •           Set Field [ invoicedetails_CUSTOMERS__billing::Follow_Up_Date_Due; Get(CurrentDate) + 14 ]
      •      
      •           Set Field [ invoicedetails_CUSTOMERS__billing::Information; "Quote Sent " & Get(CurrentDate) ]
      •      
      •           Set Field [ invoicedetails_CUSTOMERS__billing::Follow_Up_Date_Recent; Get(CurrentDate) ]
      •      
      •           Set Field [ invoicedetails_CUSTOMERS__billing::Status Date; Get(CurrentDate) ]
      •      
      •           Set Field [ invoicedetails_CUSTOMERS__billing::Followed Up; "No" ]
      •      
      •           Go to Layout [ “Dymo Invoice” (INVOICE DETAILS) ]
      •      
      •           Print Setup [ Orientation: Landscape; Paper size: 1.41" x 3.49" ] [ Restore; No dialog ]
      •      
      •           Print [ Current record; All Pages; Orientation: Portrait; Paper size: 8.5" x 11" ] [ Restore: DYMO LabelWriter 400 Turbo; No dialog ]
      •      
      •           Go to Layout [ “Quote” (INVOICE DETAILS) ]
      •      
      •           #Set Reminder
      •      
      •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Customer_Billing_fk: “$Q” AND INVOICE DETAILS::Type: “Quote” AND INVOICE DETAILS::Status Quote: “not posted” ] [ Restore ]
      •      
      •           If [ Get(FoundCount) = 0 ]
      •      
      •           Show Custom Dialog [ Title: "Message"; Message: "Quote Printed"; Default Button: “OK”, Commit: “Yes” ]
      •      
      •           Go to Layout [ “QuoteList” (INVOICE DETAILS) ]
      •      
      •           End If
      •      
      •           End If
      •      
      •           End If
      •      
      •           Go to Record/Request/Page [ Next; Exit after last ]
      •      
      •           End Loop
      •      
      •           If [ Get(LastMessageChoice) = 3 ]
      •      
      •           Exit Script [ ]
      •      
      •           End If
      •      
      •           #Print labels
      •      
      •           Set Variable [ $ID_Contact; Value:INVOICE DETAILS::ID_Customer_Billing_fk ]
      •      
      •           Freeze Window
      •      
      •           If [ Get(LastMessageChoice) = 2 ]
      •      
      •           Exit Script [ ]
      •      
      •           End If

        • 1. Re: loop not working properly on print many records
          philmodjunk

               Consider these two steps:

               Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Customer_Billing_fk: “$Q” AND INVOICE DETAILS::Type: “Quote” AND INVOICE DETAILS::Status Quote: “not posted” ] [ Restore ]

               Go to record/Request/Page [Next]

               The first step pulls up a new found set and then the go to record/request/page [next] step immediately takes you to the second record if there is one and exits if there is only one record found

               Either way, a single record from the find is skipped.

               It seems odd to start your script with no code to pull up invoice details record then and only after printing one record do you perform a find on that table. I would think that you would perform this find before the start of the loop and then loop through the found set of records that it produces.

          • 2. Re: loop not working properly on print many records

                 Hi Phil

                 I did as you suggested, but the script still left one record, unprinted. The only way I can print all the found records is by hte script below. But the loop wont end at all this time... Can you see where i am going wrong?

                 I tried to exit after last as well using your steps...

                 Thank you

                   
            •           Allow User Abort [ Off ]
            •      
            •           Set Error Capture [ On ]
            •      
            •           Set Variable [ $Q; Value:INVOICE DETAILS::ID_Customer_Billing_fk ]
            •      
            •           Set Field [ INVOICE DETAILS::Comments Quotation; TextSize( TextFont( (INVOICE DETAILS::Comments Quotation); "Times New Roman" ) ; 14) ]
            •      
            •           Commit Records/Requests [ Skip data entry validation; No dialog ]
            •      
            •           If [ not IsEmpty(INVOICE DETAILS::Printed Quote) ]
            •      
            •           Show Custom Dialog [ Title: "Warning"; Message: "Reprint this quote?"; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
            •      
            •           If [ Get(LastMessageChoice) = 1 ]
            •      
            •           Perform Script [ “RePrint Quote” ]
            •      
            •           Exit Script [ ]
            •      
            •           Else
            •      
            •           Exit Script [ ]
            •      
            •           End If
            •      
            •           End If
            •      
            •           Loop
            •      
            •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Customer_Billing_fk: “$Q” AND INVOICE DETAILS::Type: “Quote” AND INVOICE DETAILS::Status Quote: “not posted” ] [ Restore ]
            •      
            •           Go to Record/Request/Page [ Next ]
            •      
            •           Show Custom Dialog [ Title: "Message"; Message: "Do you want to print this quote?"; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
            •      
            •           If [ Get(LastMessageChoice) = 1 ]
            •      
            •           Show Custom Dialog [ Title: "Reminder"; Message: "Have you (un)checked the boxes to include the measuring/sign order form"; Default Button: “Yes”, Commit: “Yes”; Button 2: “No/Cancel”, Commit: “No” ]
            •      
            •           If [ Get(LastMessageChoice) = 2 ]
            •      
            •           Go to Field [ INVOICE DETAILS::Text_Signed Form_deposit ]
            •      
            •           Exit Script [ ]
            •      
            •           End If
            •      
            •           Commit Records/Requests [ Skip data entry validation; No dialog ]
            •      
            •           Set Variable [ $ID; Value:INVOICE DETAILS::ID_Invoice_pk ]
            •      
            •           Freeze Window
            •      
            •           Go to Related Record [ From table: “invoicedetails_INVOICEITEM”; Using layout: “Quote Print” (INVOICEITEMS) ] [ Show only related records ]
            •      
            •           Print Setup [ Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
            •      
            •           Print [ Records being browsed; All Pages; Orientation: Landscape; Paper size: 1.41" x 3.49" ] [ Restore: Letters Printer; No dialog ]
            •      
            •           Print Setup [ Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore; No dialog ]
            •      
            •           Print [ Records being browsed; All Pages; Orientation: Portrait; Paper size: 8.26" x 11.69" ] [ Restore: B&W Copy printer; No dialog ]
            •      
            •           If [ Get (LastError) = 0 ]
            •      
            •           #Set Print TimeStamp
            •      
            •           Enter Browse Mode
            •      
            •           Go to Layout [ “Quote” (INVOICE DETAILS) ]
            •      
            •           Set Field [ INVOICE DETAILS::TimeStamp_Printed Quote; Get (CurrentTimeStamp) ]
            •      
            •           Set Field [ INVOICE DETAILS::Status Quote; "Posted" & " " & Get (CurrentDate) ]
            •      
            •           Set Field [ INVOICE DETAILS::Printed Quote; Get(CurrentDate) ]
            •      
            •           Set Field [ invoicedetails_CUSTOMERS__billing::Follow Up Actions Box; "Quote Sent" ]
            •      
            •           Set Field [ invoicedetails_CUSTOMERS__billing::Follow_Up_Date_Due; Get(CurrentDate) + 14 ]
            •      
            •           Set Field [ invoicedetails_CUSTOMERS__billing::Information; "Quote Sent " & Get(CurrentDate) ]
            •      
            •           Set Field [ invoicedetails_CUSTOMERS__billing::Follow_Up_Date_Recent; Get(CurrentDate) ]
            •      
            •           Set Field [ invoicedetails_CUSTOMERS__billing::Status Date; Get(CurrentDate) ]
            •      
            •           Set Field [ invoicedetails_CUSTOMERS__billing::Followed Up; "No" ]
            •      
            •           Go to Layout [ “Dymo Invoice” (INVOICE DETAILS) ]
            •      
            •           Print Setup [ Orientation: Landscape; Paper size: 1.41" x 3.49" ] [ Restore; No dialog ]
            •      
            •           Print [ Current record; All Pages; Orientation: Portrait; Paper size: 8.5" x 11" ] [ Restore: DYMO LabelWriter 400 Turbo; No dialog ]
            •      
            •           Go to Layout [ “Quote” (INVOICE DETAILS) ]
            •      
            •           #Set Reminder
            •      
            •           End If
            •      
            •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Customer_Billing_fk: “$Q” AND INVOICE DETAILS::Type: “Quote” AND INVOICE DETAILS::Status Quote: “not posted” ] [ Restore ]
            •      
            •           If [ Get(FoundCount)=0 ]
            •      
            •           Go to Layout [ “QuoteList” (INVOICE DETAILS) ]
            •      
            •           Show Custom Dialog [ Title: "Message"; Message: "Quotes Printed"; Default Button: “OK”, Commit: “Yes” ]
            •      
            •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::Type: “Quote” AND INVOICE DETAILS::Visible quote: “=” ] [ Restore ]
            •      
            •           End If
            •      
            •           End If
            •      
            •           End Loop
            • 3. Re: loop not working properly on print many records
              philmodjunk

                   You are still performing the find inside the loop--which keeps changing the found set each time the script loops--instead of performing it a single time before the Loop step begins your loop. You are even performing a find twice--which seems especially odd.

              • 4. Re: loop not working properly on print many records

                     Ah I see - that makes sense. Yes, my script is a little off piste....need to fine tune and remove unnecessary steps...Thank you