Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FMP4 Set Field and CurrentError operation

Featured Replies

  • Newbies

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

Did you try committing the record in the script before checking for the error?

  • Author
  • Newbies

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.

  • Author
  • Newbies

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

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.

  • Author
  • Newbies

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

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)"]

My bad on this. I neglected to see the version used.

  • Author
  • Newbies

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

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.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.