• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1565
  • Last Modified:

Bypassing the When-Validate-Item trigger

I have a text item in a block for which I wrote the When-Validate-Item
trigger to do the data validation. I have a Cancel button in the block. When
I press the Cancel button I want to close the block with out any validation. Everything is doing fine
when the entered value is the valid one in the text item. But when the
validation fails it is throwing the message box from the When-Validate-Item.

How can I make the code not to execute the when-validate-item trigger
when I press the Cancel button. For all the rest of the cases it should work.

Lot of thanks in advance.
  • 2
1 Solution
Mark GeerlingsDatabase AdministratorCommented:
There are at least two ways:
1. The easiest way (if you are going to close or exit the block anyway) is to do a "clear_record" first in the logic you execute with the "Cancel" button.

2. Another way is to to do a set_item_property in your "Cancel" button logic, setting the property, item_is_valid to TRUE for the text item.
lesaAuthor Commented:
I already have a clear_record in the When-Button-Pressed trigger of Cancel button, but the when-validate-item for the text item wil be executed when the focus leaves from the text-item. So when I press the button when-validate-item trigger is bieng raised before executing the code in the when-button-pressed for the Cancel button.
Mark GeerlingsDatabase AdministratorCommented:
Yes, you are right, the when-validate-item trigger will fire first.  Does your when-validate-item raise an error if the text item is null?  If that is the problem, then move that check to the pre-insert and pre-update triggers instead.  Or, you could consider changing the validation unit in your form from the default (Item) to Record, but then you give up field-by-field validation.  Or, you can do what I have done, train the users to use the clear-record key when they need to cancel an action.
What you can do is, in the cancel button property set 'mouse navigable' to false. You can also have 'keyboard navigable' to false. This should take care of the message when you click on cancecl button.  This is happening because, when you click on cancel button the cursor navigates to the button (so your field loses the focus) causing when-validate to fire.  This can be prevented by setting the above properties.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now