krabbykabby Posted March 24, 2011 Posted March 24, 2011 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?
comment Posted March 24, 2011 Posted March 24, 2011 (edited) 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 March 24, 2011 by comment
krabbykabby Posted March 28, 2011 Author Posted March 28, 2011 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!
Recommended Posts
This topic is 4989 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now