July 13, 200916 yr Hi everyone, I'm new to the forums and glad to be here! My issue: I've written a script (and attached it to a button) that goes like this: SetVariable Go to Layout New Record/Request Set Field Perform Script It's totally functional, but the trouble is, I have a field on the layout that I want to set as "required" so that the script won't run if the field is empty. I would ideally have a custom dialogue box pop up saying, "An e-mail address is required" if that field is empty. The user would then be able to click "OK" [thus cancelling this instance of the script] and go back to fill the field. I don't want to set the field as required in the field options validation menu, because then it would not be part of the script steps. I tried this, and the script seemed confused. What script step can do this? Thank you in advance!
July 13, 200916 yr Start your script with If IsEmpty(requiredfield) Show custom dialog (with necessary info) Halt script Else then continue with your script End if [and welcome to the forums]. Edited July 13, 200916 yr by Guest
July 13, 200916 yr Author Ah, so that's how the "If" and "Else" work! Thank you--I'm learning a lot, and my script now runs perfectly. :
July 13, 200916 yr My preference would be slightly different: If IsEmpty(requiredfield) Show custom dialog (OK) Exit script End if # Now continue with your script Why? 1. The "Else" is not needed since we're going to stop the script anyway. This means you don't have to put the rest of your script inside an If statement, which makes it easier to read and maintain. 2. "Halt" is generally best avoided unless you have some particular need for it; use Exit instead. As John Hodgman would say, "That is all." :
July 13, 200916 yr The "Else" is not needed since we're going to stop the script anyway. Or the Exit Script is not needed since we're going to use Else... : I completely agree re Halt Script[] - you should never use it unless you're sure you want to force ALL scripts to stop running at that point.
July 21, 200916 yr Or the Exit Script is not needed since we're going to use Else... Sure, but as I said, I prefer to un-nest my scripts where it makes sense to do so.
Create an account or sign in to comment