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.

If Field Loop Multiple Records

Featured Replies

Hello,

I need to create a script to search all records in a found set and if a particular field for each are all the same value (0) then 'do something'.

To illustrate what i need see the attached.  

Record 1 there are 32 in total, 27 have been delivered and 5 remain
Record 2 there are 3 in total, 1 has been delivered and 2 are remaining

When the script runs to reduce the delivery remaining count I want it to check if all records for this field are now at 0 and if they are 'do something'

I suspect that I need an IF statement and a LOOP through the records but it is the "IF DeliveryRemaining = 0" for all records which i am confused at.

Hope that makes sense and someone can help.

Capture.PNG

I am not sure I follow your description fully. It looks like you would want to perform Constrain Found Set (in a new window, to preserve your current found set) and see if any records are found.

Or, if you are looping, you could something like:

Go to Record [First ]
Loop
  If [ YourTable::DeliveryRemaining ]
    Set Variable [ $rem ; 1 ]
    Exit Loop If [ 1 ]
  End If
  Go to Record [Next; Exit after last ]
End Loop
If [ not $rem ]
  # ALL RECORDS  HAVE 0 REMAINING
End If

 

2 hours ago, R81 said:

When the script runs to reduce the delivery remaining count I want it to check if all records for this field are now at 0 and if they are 'do something'

I wonder if it wouldn't be easier to create a summary field (maybe called sDeliveryRemaining' which is 'Total of DeliveryRemaining.  Then script could check this value as:

If [ not sDeliveryRemaining ]  ... then do 'the thing' you wish.

Sorry for the glitch.

Edited by LaRetta
finished calculation sentence

Yet another option: sort the found records by the DeliveryRemaining field, ascending (or descending) and check the value of the last (or first) record.

 

Even better!

  • Author

Great options! 

I will give the summary field a try later as that would probably fit easier to my script!

Thanks all.

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.