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.

Featured Replies

I wrote a script to create a new record in a related table and populate some of the fields. One of the fields is being populated by a variable that is saved from a global field before switching to the related table, and at the end of the script, I want to clear this global field. Here's what I have written: (starts from Teams table)

Commit Records/Requests

Set Variable [ $TeamsID; Value:Teams::TeamID ]

Set Variable [ $ProgramID; Value:Teams::gAllPrograms ]

Go to Layout [ “MembershipPivot” (MembershipPivot) ]

New Record/Request

Set Field [ MembershipPivot::TeamID; $TeamsID ]

Set Field [ MembershipPivot::ProgramID; $ProgramID ]

Go to Layout [ “Teams” (Teams) ]

Clear [ Teams::gAllPrograms ]

For some reason, the script creates the record I want, then clears the global gAllPrograms field and then tried to make another record in MembershipPivot! I can't figure out what is going on. Seems like it's looping but there are no loops in the script. Also, if I take out the last command, Clear [ Teams::gAllPrograms ], it only creates the one record I want and does not loop. Any ideas?

Ok, I forgot to mention that I was triggering the script using the DoScript plugin...and that seems to be where the problem is. If I trigger it instead from a button, it works fine. However, if I change the gAllPrograms field to an auto-fill with this calculation:

Let ( queueScript = mFMb_DoScript ( "CreateMembershipRecordFromTeams" ) ; gAllPrograms )

the script loops. Clearly I do not understand how this plugin works...any idea how to still trigger the script after gAllPrograms field selection, but avoid the looping issue?

Clear[] is an editing step: it actually goes into the field and clears it same way a user would - and if there is a script trigger attached to the field, Clear[] will fire it.

Try using Set Field[] instead (which is always preferable anyway). BTW, global fields are accessible from anywhere, so

Set Field [ Teams::gAllPrograms ; "" ]

will work even without going to a layout of Teams.

---

P.S. It's been a while since I used a script triggering plugin. If the script is trigerred by auto-entered calc, it will fire when the calc is evaluated, no matter how the field was modified. You will need to adjust the calc (or the script), e.g.

Case ( not IsEmpty ( TheField ) ; <<fire script>> )

Edited by comment

  • Author

Thanks! I tried Set Field before I posted and that seems to trigger the auto-enter calc as well. However, your fix for adjusting the calc worked great. It now reads:

Case ( not IsEmpty ( gAllPrograms ) ; Let ( queueScript = mFMb_DoScript ( "CreateMembershipRecordFromTeams" ) ; gAllPrograms))

instead of:

Let ( queueScript = mFMb_DoScript ( "CreateMembershipRecordFromTeams" ) ; gAllPrograms)

No more accidental looping!

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.