A READER ASKS: Go To Next Portal Doesn’t Seem To

From Dwayne Wright PMP
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts


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
Set Variable[$ClientID;Value:Invoice::ClientID_fk
If[not isEmpty(getField(INVOICE::ClientID_fk]
End If
Go to Object[ObjectName: "InvoicePort"]
Go to Portal Row
[Select First]
Set Variable [$Quant;Value:LINEITMS::Quantity]
If[not isEmpty(GwtField(LINEITEMS::Quantity))]
End If
Set Variable [$Amt;value:LINEITEMS::Amount]
If[not isEmpty(GetField(LINEITEMS::Amount))]
End If
Set Variable [$Desc;value:LINEITEMS::Description]
If[not isEmpty(getField(LINEITEMS::Description))]
End If

#Dump information into ROA table
Go to Layout["ROA"(ROA)]
Go to Object[Object Name: "ROAPortal"]
New Record/Request
Set Field[ROA:ClientID_fk; $ClientID]
Set Field[ROA:Quantity; $Quant]
Set Field[ROA:Amount; $Amt]
Set Field[ROA:Description; $Desc]
Commit Records/Requests
[No dialog]
Go to Portal Row
[Select;Next;Exit after last]
End Loop

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 info@dwaynewright.com.

© 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.