AnsweredAssumed Answered

Loop in a Loop???

Question asked by Kirk_1 on Jan 3, 2013
Latest reply on Jan 3, 2013 by Kirk_1

Title

Loop in a Loop???

Post

     This is the script im working on.

     The way its written now, if there are only 2 records, it does not recognize that there isn't a 3rd and the value of $SecondAmoutAR and $ThirdAmoutAR are the same.

     I tried a loop after the blue "Go to Record/Request/Page [ First ] below but it didn't work.

     Is there a better way to do this? I will only have up to 3 redords that it finds. I need to name them seperatly, one for each.

     I thought of a portal but not sure how to name it if they are different... $firstAmoutAR, $secondAmountAR... for each record.

     Its alreday in the correct layout...

         
  •           #Corrected Invoices
  •      
  •           Enter Find Mode [ ]
  •      
  •           Set Field [ Invoice::INPosted; "yes" ]
  •      
  •           Set Field [ Invoice::IN_isChangedReceivable; 1 ]
  •      
  •           Perform Find [ ]
  •      
  •           Go to Record/Request/Page [ First ]
  •      
  •           Loop
  •      
  •           Set Variable [ $pro; Value:Invoice::IN__PKFlgsiProNumber ]
  •      
  •           Go to Layout [ “LI_list” (InvoiceLineItem) ]
  •      
  •           Enter Find Mode [ ]
  •      
  •           Set Field [ InvoiceLineItem::LI_FKInvoice; $pro ]
  •      
  •           Set Field [ InvoiceLineItem::LIDateEntered; "12/31/2012*" ]
  •      
  •           // Set Field [ InvoiceLineItem::LIDateEntered; Get ( CurrentDate ) ]
  •      
  •           Perform Find [ ]
  •      
  •           Go to Record/Request/Page [ First ]
  •      
  •           Set Variable [ $firstAmoutar; Value:InvoiceLineItem::LIAmount ]
  •      
  •           Set Variable [ $firstDescar; Value:InvoiceLineItem::LIWhyChanged ]
  •      
  •           Go to Record/Request/Page [ Next  ]
  •      
  •           Set Variable [ $SecondAmoutAR; Value:InvoiceLineItem::LIAmount ]
  •      
  •           Set Variable [ $SecondDescar; Value:InvoiceLineItem::LIWhyChanged ]
  •      
  •           Go to Record/Request/Page [ Next ]
  •      
  •           Set Variable [ $ThirdAmoutAR; Value:InvoiceLineItem::LIAmount ]
  •      
  •           Set Variable [ $ThirdDescar; Value:InvoiceLineItem::LIWhyChanged ]
  •      
  •           Go to Record/Request/Page [ Next; Exit after last ]
  •      
  •           Go to Layout [ “LP_List” (PayableLineItem) ]
  •      
  •           Enter Find Mode [ ]
  •      
  •           Set Field [ PayableLineItem::LP_FKInvoice; $pro ]
  •      
  •           Set Field [ PayableLineItem::LPDateChanged; "12/31/2012*" ]
  •      
  •           // Set Field [ InvoiceLineItem::LIDateEntered; Get ( CurrentDate ) ]
  •      
  •           Perform Find [ ]
  •      
  •           Set Variable [ $firstAmoutAP; Value:PayableLineItem::LPAmount ]
  •      
  •           Go to Record/Request/Page [ Next ]
  •      
  •           Set Variable [ $SecondAmoutAP; Value:PayableLineItem::LPAmount ]
  •      
  •           Go to Record/Request/Page [ Next ]
  •      
  •           Set Variable [ $ThirdAmoutAP; Value:PayableLineItem::LPAmount ]
  •      
  •           Go to Layout [ “Corrections” (Corrections) ]
  •      
  •           New Record/Request
  •      
  •           Set Field [ Corrections::Cor_FirstCorrected_AR_Amount; $firstAmoutar ]
  •      
  •           Set Field [ Corrections::Cor_FirstCorrected_AP_Amount; $firstAmoutAP ]
  •      
  •           Set Field [ Corrections::Cor_SecondCorrected_AR_Amount; $SecondAmoutAR ]
  •      
  •           Set Field [ Corrections::Cor_SecondCorrected_AP_Amount; $SecondAmoutAP ]
  •      
  •           Set Field [ Corrections::Cor_ThirdCorrected_AR_Amount; $ThirdAmoutAR ]
  •      
  •           Set Field [ Corrections::Cor_ThirdCorrected_AP_Amount; $ThirdAmoutAP ]
  •      
  •           Set Field [ Corrections::Cor_FirstCorrected_AR_Desc; $firstDescar ]
  •      
  •           Set Field [ Corrections::Cor_SecondCorrected_AR_Desc; $SecondDescar ]
  •      
  •           Set Field [ Corrections::Cor_ThirdCorrected_AR_Desc; $ThirdDescar ]
  •      
  •           Set Field [ Corrections::Cor_PK_ProNumber; $pro ]
  •      
  •           Go to Record/Request/Page [ Next; Exit after last ]
  •      
  •           End Loop
  •      
  •           If [ Get ( FoundCount ) and not Get ( LastError ) ]
  •      
  •           Go to Layout [ “Print Corrected Invoice ” (Invoice) ]

Outcomes