McG Posted September 6, 2009 Posted September 6, 2009 Have a script that (or hopefully will have) that performs a search automatically on user opening a file. If their user name and current date already exist in a particular field, then the script goes to that record, which they will then amend. If the search returns no results then a new record is created. How do I get a script step to say, "if no records found do x" and also how do I get the the dialogue for no records match this set to NOT appear. Thanks.
IdealData Posted September 6, 2009 Posted September 6, 2009 How do I get a script step to say, "if no records found do x" and also how do I get the the dialogue for no records match this set to NOT appear. The clue here is to use Set Error Capture to ON in your script. Error capture remains in effect until you do a Set Error Capture [OFF] or the script terminates, or passes to another script. When error capture is on then you have control in the script. You must test for the last error using Get(LastError). Based on the number returned (see the help system for error codes) you can then direct you script accordingly - this will also suppress the standard FM dialog box, so you could use your own custom dialog too.
bcooney Posted September 6, 2009 Posted September 6, 2009 You probably will end up with this structure in your script: Set Error Capture ON Enter Find Set Field AccountName , Get (AccountName) Perform Find If (GetFoundCount) = 0 do this Else do this End If
McG Posted September 6, 2009 Author Posted September 6, 2009 Thanks very much gents. I've seen Set Error On many times in scripts and never saw the point to it. I do now. Problem solved.
Vaughan Posted September 7, 2009 Posted September 7, 2009 The clue here is to use Set Error Capture to ON in your script. Error capture remains in effect until you do a Set Error Capture [OFF] or the script terminates, or passes to another script. No. Error Capture state is passed on to all sub-scripts too. I had a problem last week (exporting XML files from a container field) and the real problem was masked by a "Set Error Capture [on]" step in one of the dozens of scripts that the process called earlier in its running. Grrr. My recommendation is to set error capture off after it's no longer required.
IdealData Posted September 9, 2009 Posted September 9, 2009 Thanks Vaughan - I stand corrected. Personally I've always explicitly used Error capture ON in EVERY script so I would never have spotted that.
Recommended Posts
This topic is 5555 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