September 6, 200916 yr 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.
September 6, 200916 yr 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.
September 6, 200916 yr 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
September 6, 200916 yr Author 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.
September 7, 200916 yr 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.
September 9, 200916 yr Thanks Vaughan - I stand corrected. Personally I've always explicitly used Error capture ON in EVERY script so I would never have spotted that.
Create an account or sign in to comment