Symantec IGA

 View Only
  • 1.  How to assign js value to screen logical attribute?

    Posted Oct 17, 2018 12:22 PM

    Hi,

    In IDM task, I have a HTML element. In this, using javascript, I'm reading the browser URL and setting the value to an HTML input field named "testAttr". Now, I want to set this value to screen logical attribute. (Note: the value is set correctly in "testAttr" html input field) In the initialization javascript I have,

    function init(ScreenContext) {
    var abc=document.getElementById("testAttr").value;
    ScreenContext.setFieldValue("|displayAttr|",abc);
    return true;
    }

    But the value is not set in |displayAttr| logical attribute.

     

    One other approach was, getting the browser URL in the initialization javascript like below.

    function init(ScreenContext) {
    var abc=window.location.href;
    ScreenContext.setFieldValue("|displayAttr|",abc);
    return true;
    }

    Even the above code did not work.

     

    Any help on this is highly appreciated.

     

    Thanks,

    KR

     



  • 2.  Re: How to assign js value to screen logical attribute?
    Best Answer

    Posted Oct 17, 2018 02:05 PM

    Hello KR, 

     

    I played with your code a bit and did some testing in my own environment. I am not sure if it is your screen logical attribute causing the problem, or your variable. 

     

    I tested this just to make things a little simpler and it worked as expected: 

    function init(ScreenContext) {
    var abc="testing";
    ScreenContext.setFieldValue("Title",abc);
    return true;
    }

     

    When I tried to put your second set of code into my system I got an error that Window was not defined. 

     

    Are you seeing an error or just a failure to populate? 

     

    Instead of populating the field of |displayAttr| on your screen, set the attribute value and then have that value print out on the screen to confirm it is being initialized correctly. If that works then the problem is with setting that particular attribute and we can explore that further. If the data that prints out on the screen is wrong or blank we can look at how you're getting that value into the attribute. 



  • 3.  Re: How to assign js value to screen logical attribute?

    Posted Oct 18, 2018 03:16 PM

    Hi leije03,

     

    Thanks for the response.Like you mentioned I got the error that Window is not defined.

     

    But I was able to achieve the result with the following script placed in "HTML to appear at the end of the page" section.

     

    <script>

    var url= window.location.href;
    document.getElementById("displayAttr").value=url;

    </script>

     

    Thanks,

    Kalpana