Purchase your Section 508 Compliance Support guide now!

Purchase your Section 508 Compliance Support guide now!

Report Studio -- use HTML item to get current user

This is an example of using a javascript function in a Cognos Report Studio report to get the current user.

 

  1. Create a new report in Cognos Report Studio
  2. Create a new prompt page and add a HTML item control to the page.
  3. Add the following .js code to the HTML item
  4. When the form loads you should see an alert box with the current logged in username

 

<script>

function init(){

            getFormElements()

}

 

function getFormElements(){

            for (i=0; i<document.forms["formWarpRequest"].elements.length; i++){

                        if(document.forms["formWarpRequest"].elements[i].name == "ui.username"){

                                    alert('THIS IS THE USER: ' + document.forms["formWarpRequest"].elements[i].value);

                        }

 

            }

}

</script>

<body onLoad=init()>