Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

loop to add multiple records from found set

Featured Replies

I have two tables - Charges and Order Charges. I do a find for all Charges matching the specified Industry and Product. This part is working perfectly, returning 3 records in the Charges found set for the data I'm testing with.

What I can't figure out is how to add a new Order Charges record for each record in the Charges found set. Please see my script below. Thanks in advance for any suggestions on how I can add the new Order Charges records from the Charges found set.

Commit Records/Requests [ No dialog ]

Set Variable [ $OrderID; Value:"gOrderID" ]

New Window [ ]

Go to Layout [ “Masterfile - Charges” (Charge) ]

Enter Find Mode [ ]

Set Field [ Charge::IndustryProduct; Get (ScriptParameter) ]

Perform Find [ ]

# above works, below does not.

Go to Record/Request/Page [ First ]

Loop

Set Variable [ $ChargeID; Value:Charge::ChargeID ]

Set Variable [ $ChargeDescription; Value:OrderCharge::ChargeDescription ]

Set Variable [ $Quantity; Value:OrderCharge::Quantity ]

Set Variable [ $Rate; Value:OrderCharge::Rate ]

Set Variable [ $UnitOfMeasure; Value:OrderCharge::UnitOfMeasure ]

Set Variable [ $BillingFrequency; Value:OrderCharge::BillingFrequency ]

Set Variable [ $BillingMode; Value:OrderCharge::BillingMode ]

Go to Layout [ “OrderChargesTableView” (OrderCharge) ]

New Record/Request

Set Field [ OrderCharge::OrderID; $OrderID ]

Set Field [ OrderCharge::ChargeID; $ChargeID ]

Set Field [ OrderCharge::ChargeDescription; $ChargeDescription ]

Set Field [ OrderCharge::Quantity; $Quantity ]

Set Field [ OrderCharge::Rate; $Rate ]

Set Field [ OrderCharge::UnitOfMeasure; $UnitOfMeasure ]

Set Field [ OrderCharge::BillingFrequency; $BillingFrequency ]

Set Field [ OrderCharge::BillingMode; $BillingMode ]

Commit Records/Requests

Go to Layout [ “Masterfile - Charges” (Charge) ]

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

End Loop

So what isn't working?

At a guess you probably need to set the ChargeID to that of the new record, not the old one.

  • Author

The script steps after the # comment step do not seem to execute.

The OrderCharges for adding all belong to the same Order and that's why the OrderID doesn't change within the loop. The primary key for OrderCharges is OrderChargeID and it is generated automatically.

Is there a found set after the Perform Find?

I cannot see anything in the code that looks broken.

  • Author

Solved it.

Where I had:

Set Variable [ $OrderID; Value:"gOrderID" ]

it was storing the literal gOrderID, when I really wanted to specify the global field there. Once I did that, it worked fine. (I did find a couple of other problems, but solved those as well.)

I don't think I could have solved it without the feedback from this board telling me that I was on the right track. Many thanks to all.

Hal

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.