AnsweredAssumed Answered

Issues with a loop script

Question asked by thezed on Jul 6, 2009
Latest reply on Jul 7, 2009 by thezed

Title

Issues with a loop script

Post

Hi, I am a newbie with FM and am trying to get a Loop script working. 

 

My first table, Sales Invoices, contains all the invoices, each of them with a field Job Number (each invoice is indeed linked to a Job). There can be several invoices per Job Number. My second table, Job Numbers, contains all the jobs. In this table, i would like to add a field that gives the total amount invoiced per Job Number. 

I have named this field Total_Invoiced and set its value to Calculation '=$$Sum', ie the result of the below script). But nothing happens....

 

Set Variable [$$JN; Value:GetField (Job Numbers::Job Number)]

Set Variable [$$Sum; Value:0]

Go to Layout ["Sales Invoices" (Sales Invoices)]

Go to Record/Request/Page [First]

Loop

   If [Sales Invoices::Job_Number = $$JN]

      Set Variable [$$Sum; Value:$$Sum + Sales Invoices::Amount USD

      Go to Record/Request/Page [Next; Exit after last]

   Else

      Go to Record/Request/Page [Next; Exit after last]

   End If

End Loop

Go to Layout [original layout]

 

 

Thanks for your help! 

Outcomes