AnsweredAssumed Answered

portal loop in a loop

Question asked by vmtc on Dec 18, 2013
Latest reply on Dec 20, 2013 by philmodjunk


portal loop in a loop


     I'm trying to create related records via a portal loop, but can't get the set field to work properly. My layout is based on a table called Formats, that connects two other tables (Copyright and Statement) which have a many-to-many relationship. I've created a List of the Copyright values in Formats, which give the values to be set in the Statement Portal.

     What happens is that it cycles through the loop, but only sets one field, and that is with the last value. Curiously, when the first record is already in the Statement Portal,  even though I've not bothered taking this into account with the script, it seems to skip over it. I say this because if there are 7 records in total, you end up with two portal values, being the first and the 7th, but not the ones in between. When I take the first value away, I end up with one portal row, with the last value in it. 

     Here are the steps I am using:


     Set Variable ($RowCount; Value: Formats:CountCopyS (count of fields from copyright portal, ie rows to be copied)

     Set Variable ($row; Value: 0)

     Go to Object [Object Name: "StatementPortal"]

     Go to Portal Row [First]


     Set Variable [$row; Value: $row +1]

     Set Variable [$CopyS; Value: GetValue (Formats:List Copyright; $row)]

     Set Field [Statement:CopyrightS; $CopyS]

     Exit Loop If [$row = $RowCount]

     Go to Portal Row [Next]

     End Loop

     Go To Record/.. [Next; Exit after last]

     End loop


     Any help would be much appreciated. I'm using Filemaker 10Adv