Jump to content

Unique Value Check During Data Entry


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

Recommended Posts

Good day Gurus,

I am trying to check if a record exist during data entry and if it does display a "new windows" with a warning, to accomplish this i am using btih "Set Script Triggers" and error capture in the below script but don't seem to work.

Field: kDocumentNumber - "Unique value" is checked

Data Entry Window:

image.png.8bebe6d8533aed4130a9abbff2b1d7a4.png

Warning Message Windows

image.png.934cfe377c1761e1350eaa5a7f7bb7bf.png

Script i executing on exit using Trigger, here i am using  

image.png.dd2996961fb27d13577d72bb33bb7a82.png

The idea is if error "504" is capture show a new windows. if not exit script.

What i am doing wrong or am i using the wrong approach to show a new windows based on an error.

Any Help is greatly appreciated

Thanks

Rudy.

image.png

Link to comment
Share on other sites

Your script cannot work the way you want.  

The Get(LastError) function returns the error number for the most recently executed script step. In your script, the most recently executed script step is Set Error Capture[] - and this will never return an error, let alone error #504. 

In order to get a validation error, you must attempt to validate the field - and you must do this before the field is validated normally. Otherwise your window will open after the built-in validation error message, not instead (if at all). Try triggering the following script OnObjectValidate:

Set Error Capture [ On ]
# TRY TO EXIT THE FIELD
Go to Next Field
Set Variable [ $error; Value:Get ( LastError ) ] 
If [ $error ]
   Go to Previous Field
   Show Custom Dialog [ Message: "Your custom message can be here, or in a new window." ]
   # CANCEL TRIGGERRING EVENT
   Exit Script [ Result: False ]
End If

Note that the error number here will be 1, not 504 (I am not entirely sure why).

 

Edited by comment
  • Like 1
Link to comment
Share on other sites

5 hours ago, comment said:

Note that the error number here will be 1, not 504 (I am not entirely sure why).

After some more experimenting:

You will get error #504 if, instead of exiting the field, you try to commit the record. However, this has the side effect of committing the record in case the entered value is not a duplicate. You may not want to commit the record at this point. 

 

Link to comment
Share on other sites

  • 4 weeks later...

thanks, go tot to work like a charm.

On 9/10/2019 at 11:47 AM, comment said:

After some more experimenting:

You will get error #504 if, instead of exiting the field, you try to commit the record. However, this has the side effect of committing the record in case the entered value is not a duplicate. You may not want to commit the record at this point. 

 

 

Link to comment
Share on other sites

This topic is 1661 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.