Forum Stats

  • 3,826,793 Users
  • 2,260,707 Discussions
  • 7,897,074 Comments

Discussions

Validation in screenflow forms

710494
710494 Member Posts: 16
Hi,

I have a problem with validations in form. I have a business object AbcBO who has 3 fields a,b and c. Now I want to put some validations for these fields. Please help me in implementing validations..

Best Answer

  • Dan Atwood
    Dan Atwood Member Posts: 2,313 Gold Trophy
    Answer ✓
    If it was just two fields you could create a method that compared the two and then put the method in each of the fields "On Change Invoke" property (click the field on the presentation -> click the "Properties" tab -> select the method from the dropdown in the "On Change Invoke" property). Here the method is invoked whenever you lose focus after changing one of the two fields.

    Since you have three or more fields, you would instead need to do your cross field validation when the user clicks the "Submit" button. Here are the steps you'd do to accomplish this:

    1) Create a method. Call it something like "onSubmitValidation". The logic in this method might look something like this:
    if (a != b) && (b > c) then
        submit("submit")
    else
        showError("a cannot be equal to b and b has to be greater than c")
    end
    2) In the presentation, change the "Submit" button's "Action" property from "submit" to "action" (click the Submit button -> click the "Properties" tab -> click the field next to the "Action" property and select "action" from the dropdown)

    3) In the presentation, associate your new validation method with the Submit button (with the "Submit" button still selected, in the "Properties" tab click the "Method Invoked" property -> click your new method created in the first step from the methods listed in the dropdown).

    Dan

Answers

  • Dan Atwood
    Dan Atwood Member Posts: 2,313 Gold Trophy
    Answer ✓
    If it was just two fields you could create a method that compared the two and then put the method in each of the fields "On Change Invoke" property (click the field on the presentation -> click the "Properties" tab -> select the method from the dropdown in the "On Change Invoke" property). Here the method is invoked whenever you lose focus after changing one of the two fields.

    Since you have three or more fields, you would instead need to do your cross field validation when the user clicks the "Submit" button. Here are the steps you'd do to accomplish this:

    1) Create a method. Call it something like "onSubmitValidation". The logic in this method might look something like this:
    if (a != b) && (b > c) then
        submit("submit")
    else
        showError("a cannot be equal to b and b has to be greater than c")
    end
    2) In the presentation, change the "Submit" button's "Action" property from "submit" to "action" (click the Submit button -> click the "Properties" tab -> click the field next to the "Action" property and select "action" from the dropdown)

    3) In the presentation, associate your new validation method with the Submit button (with the "Submit" button still selected, in the "Properties" tab click the "Method Invoked" property -> click your new method created in the first step from the methods listed in the dropdown).

    Dan
This discussion has been closed.