• Emil Brolin
    February 27, 2017 at 12:42 am #3851

    Hi!

    I have a function to check all validation errors in a form which is triggered by the submit button of the form. Somehow I get my invalidViews wrong, since it never gets set by the function. Any ideas?

    function checkPage() {
    var invalidViews = bpmext.ui.getInvalidViews(page.ui.get(“Vertical_Layout1”));

    if(invalidViews.length > 0) {
    var modal = page.ui.get(“ValidModal”);
    modal.setTitle(“Validation error”);
    modal.setText(invalidViews.length + ” errors must be fixed.”);
    modal.setVisible(true);

    return false;
    }
    }

    SPARK Support
    February 27, 2017 at 3:00 pm #3869

    Hi Emil,

    Your code looks good to me.  I would suggest testing the code manually through the console to verify the control names are correct.  Also, try adding some console.log() statements to verify you are flowing through your logic correctly.

     

    <script>
    function checkPage() {

    console.log(“got in the function”);

    var panel = page.ui.get(“Panel1”);
    var invalidViews = bpmext.ui.getInvalidViews(panel);

    if(invalidViews.length > 0) {
    console.log(“there are errors”);
    return false;
    }
    }
    </script>

    Regards,

    Stephen P.

    Emil Brolin
    February 27, 2017 at 11:44 pm #3876

    Tried to re-create the scenario you’ve got up there, but I stil doesen’t get any errors printed out.

    <script>

    function checkPage() {
    console.log(“In the function”);
    var panel = page.ui.get(“Panel1”);
    var invalidViews = bpmext.ui.getInvalidViews(panel);

    console.log(invalidViews.length);
    if(invalidViews.length > 0 ) {
    console.log(“Errors”);
    return false;
    }

    }
    </script>

    The validation works just fine. I’ve got “me.setValid(me.getText().length > 0, “Mata in någon text! (Validation error client side)”);” on the onBlur event.

    But i looks like “var invalidViews = bpmext.ui.getInvalidViews(panel);” is not set at all.
    I’m using BPM 8.5.7 and Spark 4.4.8.1.

    / Emil

    SPARK Support
    March 1, 2017 at 10:33 am #3898

    Hi Emil,

    I used a Panel control to contain the other controls in my example.

    You need to reference the layout control that use are using to hold all of your controls.  Try running the code from the console first.

    layout = page.ui.get(“layout Control Name”);

    invalidViews = bpmext.ui.getInvalidViews(layout);

    invalidViews.length;

    (See attached screenshot)

    Regards,

    Stephen P.

     

    Shivani Goyal
    November 15, 2017 at 10:20 am #4804

    I have a text box as email address field and have a regular expression to validate that email address..I am calling a function on click of a button and have used the below code in the called function in the custom HTML. But the below validation code is not working because invalidView.length always return me 0 even if the email address in invalid . Kindly suggest me something for this.

    <script>
    function validatePage()
    {
    var invalidView = bpmext.ui.getInvalidViews();
    console.log(invalidView.length +” -is the length”);
    if(invalidView.length>0)
    {
    var modalAlert = page.ui.get(“Modal_Alert1”);
    modalAlert.setTitle(“Validation Errors”);
    modalAlert.setText(invalidView.length+” must be resolved to continue”);
    modalAlert.setVisible(true);
    return false;
    }

    }
    </script>

    SPARK Support
    November 15, 2017 at 10:51 am #4805

    Hi Shivani,

    Is Text control showing the red outline with the X icon?

    What happens when you call bpmext.ui.getInvalidViews() manually from the console?

    Which version of SPARK and BPM, including CF version, are you using?

    Regards,

    Stephen P.

    Shivani Goyal
    November 15, 2017 at 10:30 pm #4809

    Hi Stephen

    Yes, the text control is showing the error message. Even from console it returns me an empty array. PFA

    Note:- IBM BPM 8.5.7 and Spark UI 4.4.8.1CE

    Regards

    Shivani

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Start typing and press Enter to search