Symantec IGA

Expand all | Collapse all

Validation Javascript on User Identification Page

Jump to Best Answer
  • 1.  Validation Javascript on User Identification Page

    Posted 09-06-2018 05:38 AM

    Hello,

     

    I have created an Identify User Screen where user enters value of 3 attributes (attribute1, attribute2 and attribute3) in order to be identified.

    There is another attribute, attribute4 which is a hidden attribute on the Identify User Search Screen and it comes from a different data source.

     

    As per the design attribute4 is the string sum of attribute1, attribute2 and attribute3.

     

    I need to prepare a validation javascript that would validate that if the string sum of the value of attribute1, attribute2 and attribute3 which the user is entering is equals to attribute4.

     

    I need help in the scripting part where I need to search the user on basis of the entered value by the user for attribute1, attribute2 and attribute3 and consequently evaluate the string sum against attribute4. 

     

    Please help me on the same and also, one more query, how to read the value of a hidden attribute? Use Screencontext.getFieldValue() ?

     

     

    Code That I have Written (Missing the searching User Part for which I need Help):

     

    function validate(Screencontext, errorMessage)
    {
    var answer1 = String(Screencontext.getFieldValue("attribute1"));
    var answer2 = String(Screencontext.getFieldValue("attribute2"));
    var answer3 = String(Screencontext.getFieldValue("attribute3"));
    var answer4 = String(Screencontext.getFieldValue("attribute4"));
    var newAnswer = answer1+answer2+answer3+answer4;
    if ( newAnswer != answer4)
    {
    errorMessage.reference = "Error Mismatch: Attribute4"
    return false;
    }
    }

     

    Thanks & BR
    Sandipan



  • 2.  Re: Validation Javascript on User Identification Page

    Posted 09-06-2018 08:35 AM

    Wouldn't this function need to add up the values of 1+2+3 and compare it to 4 like this? In your original script you added up all 4 values and then compared that to attribute 4. This approach doesn't work because 1+2+3+4 should never == 4 so you'll never get your error message. 

     

    Your getFieldValues are correct, even with a hidden attribute you should be able to use that function, but I don't think you need to specify string like this. 

     

    function validate(Screencontext, errorMessage)
    {
    var answer1 = Screencontext.getFieldValue("attribute1");
    var answer2 = Screencontext.getFieldValue("attribute2");
    var answer3 = Screencontext.getFieldValue("attribute3");
    var answer4 = Screencontext.getFieldValue("attribute4");
    var newAnswer = answer1+answer2+answer3;
    if (newAnswer != answer4)
    {
    errorMessage.reference = "Error Mismatch: Attribute4"
    return false;
    }

    return true;
    }



  • 3.  Re: Validation Javascript on User Identification Page
    Best Answer

    Posted 09-06-2018 01:42 PM

    I replied to another post of yours with the below which I think was for the same thing.

    https://communities.ca.com/message/242139502-re-validation-javascript-and-using-the-validate-function?commentID=24213950… 

     

    You can take a look at the following as this might help you in scripting your own requirements.

    Restricting the users from using First Name or Las - CA Knowledge