From Dwayne Wright PMP
Certified FileMaker Developer
A READER ASKS
I am attempting to copy data from one portal to another using a loop to copy each line of the first portal. It copies the first line OK but does not go to the next row. It just loops around and around the first row. I just can’t see what is wrong.
I am using Filemaker 9 Pro, code attached. I would be very grateful for any pointers.
Enter browse mode
Go to Object[ObjectName: "InvoicePort"]
Go to Portal Row
Set Variable [$Quant;Value:LINEITMS::Quantity]
Set Variable [$Amt;value:LINEITEMS::Amount]
Set Variable [$Desc;value:LINEITEMS::Description]
#Dump information into ROA table
Go to Layout["ROA"(ROA)]
Go to Object[Object Name: "ROAPortal"]
Set Field[ROA:ClientID_fk; $ClientID]
Set Field[ROA:Quantity; $Quant]
Set Field[ROA:Amount; $Amt]
Set Field[ROA:Description; $Desc]
Go to Portal Row
[Select;Next;Exit after last]
The Commit Records script step is the problem. When you commit a record, you exit the record as well. This takes you out of the portal completely, so the Go To Next means that since you are not in the portal anymore (due to exiting the record), you are going to the first row again.
Before you exit the record, set a variable equal to the portal row number. Commit the record, go back to the Portal Row number by using the variable information and then use your Go To Next Portal Row [exit after last]. You could also go to the portal row variable plus 1 and then tweak your exit loop conditional.
More info about the author and FileMaker in general, contact me at firstname.lastname@example.org.
© 2009 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.