Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6016 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted (edited)

Hi:

My question is about the value of CurrentError after setting a field value in a script.

I have a script that sets a field and the field is defined to contain unique values only. When my script sets the field with a duplicate value I do not get the expected error '504 Value in field does not meet unique value validation entry options' in the 'CurrentError' function and therefore can not handle the error condition in the script. Does anyone know why the Set Field script command would be successful in bypassing the validation rules set for the field?

Here's my short script:

Set Error Capture [On]

Set Field ["Management IP Address",""10.1.4.208""]

If ["Status(CurrentError) <> 0"]

  Show Message ["Management IP Address Validation Error"]

  Exit Script

End If

Thanks in advance.

Dale

Edited by Guest
  • Newbies
Posted

I did try a "Goto Next Field" immediately after the "Set Field" to see if that enforced the validation check, but it didn't do anything either. I'll try a couple of other navigational type commands and a flush to disk to see if that triggers the validation.

Thanks.

  • Newbies
Posted

Using the idea of a "commit" I've determined that if I preceed my Set Field command with a "Goto Field" command and then after I Set the field I add the command "Exit Record/Request", I can successfully perform the error check.

Here's my updated script:


Set Error Capture [On]

Goto Field ["Management IP Address"]

Set Field ["Management IP Address",""10.1.4.208""]

Exit Record/Request

If ["Status(CurrentError) <> 0"]

  Show Message ["Management IP Address Validation Error"]

  Exit Script

End If 

Thanks for the tip which led to this resolution.

Dale

Posted

There is no commit in version 4, and IIRC validation occurs only on user entry - not when the field is set by Set Field.

By going to the field first, your script simulates manual entry - but I believe the Exit Record and the following steps will NOT be executed when validation fails.

  • Newbies
Posted

Hi:

I've tested various commands in place of the "Exit Record/Request" and this is the only command that allowed for successful error checking and handling. The other commands I tried such as: "Goto Next Field", "Enter Browse Mode" or "Flush to Disk" all cause the srcipt to throw a typical user level error message that halts the script prior to error checking, as you suggested.

Dale

Posted

I tried it with this script:

Set Error Capture [On]

Goto Field ["UniqueValue"]

Set Field ["UniqueValue","gValue"]

Exit Record/Request

Set Field ["gError","Status CurrentError)"]

What happens is that gError does get set to "504", but the cursor remains in the UniqueValue field. Attempting to exit the field after the script has run triggers the validation. So I'd say yes error checking, but no error handling.

However, if all you wanted is to stop the execution of the rest of the script, then yes - that would work, as long as the field is on the layout. The error is generated when you try to exit the field (and wouldn't be generated if the cursor was not in the field). Therefore, the two steps, Goto Field[] and Set Field[], can be replaced by a single one:

Set Error Capture [On]

Paste Result [select, "UniqueValue","gValue"]

Exit Record/Request

Set Field ["gError","Status CurrentError)"]

  • Newbies
Posted

Thanks for the tip about using the Paste Result, it does the same thing in one command that I was doing in two commands.

In my script I do not set a global field with the error code after the Exit Record/Request. If I do that, then yes the script will terminate as the field validation fails and throws a user error message to the screen, instead I immediately check the error status after the Exit Record/Request. This allows me to check the success of the Paste Result and make a decision about what to do next depending on the error code. My script in practice is more elaborate than the snippet I posted here. The script actually sets an IP address and if that address violates the validation rule of the field then I increment the IP address via a Loop and Paste in a new value. Again if the address violates the rule I continue until I get to an address that is unique in the database and exit the Loop. The script works well for the task I need it to complete.

Dale

Posted

I do not set a global field with the error code after the Exit Record/Request. If I do that, then yes the script will terminate as the field validation fails and throws a user error message to the screen

Actually no, the script continues AFTER the error - otherwise the global field wouldn't get set. The validation error comes up only after the script has run, when I try to move away from the validated field.

If I had to do this, I would forego field validation and do my own checking within the script. I'd prefer that to simulating manual entry and being dependent on the field's presence on the layout.

This topic is 6016 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.