Portal endless loop problem
I have a script to get information from portal rows but it ends up doing an endless loop. Here is the script, any help would be greatly appreciated.
Each time you change layouts, the portal row loses the focus. When you return to the layout and go to next portal row, this step always executes from the context of the first portal row and you never advance through the row. There are almost always better ways to loop through related records without directly interacting with a portal.
It appears that you have this relationship:
Is the match field between the two records Vendor Number?
Otherwise, it would appear that you are creating a new set of orders records without any new purchases record to link to it.
Leaving those issues aside for the moment, you can set variables to lists of values from your related records and loop though these lists instead of your portal row. This assumes that your portal to Orders is unfiltered.
Set Variable [$Quantitites ; value: List ( Orders::Qty ) ]
Set Variable [$Vendors; value: List ( Vendor Number ) // this list function is not needed if Vendor Number is the match field ]
Go to Layout ["orders" (orders)]
Set Field [$K ; value: $K + 1 ]
exit loop if [$K > valueCount ( $Quantities ) ]
Set Field [Orders::Qty ; GetValue ( $Quantities ; $K ) ]
Set Field [Vendor Number::GetValue ( $Vendors ; $K ) ]
Go to Layout [original layout]
You have no way to exit the loop. You will either need a Exit Loop if script step, or Go to Record/Request/Page script step, check Next in the dropdown on the bottom right of the window, and check the box 'Exit After Last'
edit: Phil was typing a lengthy (better) response the same time I was....go with Phil......always Phil :)
No, not always me, I can make mistakes and sometimes can't see the obvious. So always consider all suggestions posted carefully and never assume any one poster is always correct. We are human after all...
WE are human....you...can't be sure.....superFileMaker human...at least :)
Thank you so much for your help. That solved the problem!
Retrieving data ...