Validation of rule on button submit should not start the process when evaluated to be false

We have a requirement where a rule has to be evaluated which has to happen at a button click and we have 3 buttons which needs this rule to be evaluated wrapped in a cardlayout.

Now the do we have any mechanism to evaluate the rule when any button is clicked and throw a error message when rule is not evaluated as true. Please note that all the buttons have processes in them and we should not execute the process when the rule is false.

Thanks in advance!!!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Please look into the slightly lesser-known a!validationMessage() component, as I've been able to successfully use it when I've had use cases that sound similar to yours.  Namely, it allows you to throw section-level or form-level validation that validates when any submit button is clicked.

  • Hi Mike,

    In out application we have card  layout aof the nd buttons inside it not section or form level. Let me rephrase my question.

    we have a user for whom a request was assigned and super user can assign the same request to another user from back end. when this user is having static screen , we have coded validation within "with", problem comes when the user opens that request and kept the screen as static and in mean while from backend super user changes it to some other user. For  the current  user as the screen is static he doesnot know that request is assigned to another user, when he performs any updates on the fields of the  request the code with in "with" gets evaluated and displays the message we intended to, but when he doesnot update any field and clicks on the button it doesnot give the message we want to show (  this is happening because the whole cardlayout is in load and the buttons are in with, so first time it loads the request will be in his name only and the buttons validation also have the user name only, so when it is changed from back end that will not get update until the "with" gets executed and as the user is not updating any field in the cardlayout the button validation is still having the user as current user).

     Hope this helps in understanding the issue.

  • I'm pretty sure I understand your issue, at least generally.  The component I named (a!validationMessage()) works regardless of what style of buttons you're using or where they are - you set it to validate on form submit and that's what it does.

    Additionally you might want to move the query logic used in your validation into the saveInto of the button(s) itself.  In this way, you can force the re-execution of the query when the user tries to click on a submit button/link, and combined with the "on submit" a!validationMessage(), you can probably keep the form from submitting in an invalid condition.  I'll do a little testing on my end to see if I can confirm whether this is true or not. [edit: see below]

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    I take that back - I forgot that the saveInto() of a button click doesn't execute until validations pass, so my suggestion above never quite works out.

    Does the user interact with the form at all before clicking any of the submit buttons/links?  If you put your validation rule in a with() variable or (preferably) an a!refreshVariable variable with "refreshAlways" set to TRUE (as suggested previously by the other commentor), then any time a user interacts with the form prior to clicking the submission button/link will re-try the validation logic.

    If not, I'm afraid you might need to compromise and use some sort of 2-click submit functionality, like having one button/link that forces the validation to re-run and save the result locally, and only after that's done (and the validation passes) you allow the Submit buttons/links to actually submit the form.

Reply
  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    I take that back - I forgot that the saveInto() of a button click doesn't execute until validations pass, so my suggestion above never quite works out.

    Does the user interact with the form at all before clicking any of the submit buttons/links?  If you put your validation rule in a with() variable or (preferably) an a!refreshVariable variable with "refreshAlways" set to TRUE (as suggested previously by the other commentor), then any time a user interacts with the form prior to clicking the submission button/link will re-try the validation logic.

    If not, I'm afraid you might need to compromise and use some sort of 2-click submit functionality, like having one button/link that forces the validation to re-run and save the result locally, and only after that's done (and the validation passes) you allow the Submit buttons/links to actually submit the form.

Children
No Data