If you are unable to create a new account, please email support@bspsoftware.com

 

Javascript Not working in Cognos viewer(Portlet), But Working in Report studio

Started by Anantula, 15 Sep 2011 07:00:42 PM

Previous topic - Next topic

Anantula

Hello Gurus,

I am trying to show a custom phrase as the default selection in a value prompt. I used JavaScript for that which worked perfectly fine through report studio. But when I tried to run that report through Cognos Viewer Portlet, it seems JavaScript is not working.

Cognos version 8.4

JavaScript:
<script> document.formWarpRequest._oLstChoicesState[0].text = 'NATIONAL'; </script>

"State" is my value prompt name

I know that the script will be bit different when you try to run them as dashboards/portlets.
Can some body please help me out as the project ready to go live?

Thank you in advance.

Best Regards,
Anan


bdbits

Maybe you just did not include it, but your javascript is missing some stuff. Try this - I believe it will work in both RS and the portlet.

<script type="text/javascript">
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (!fW || fW == undefined) {
  fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );
}
fW._oLstChoicesState[0].text = 'NATIONAL';
</script>

But, that is actually going to change the text of the first item in your dropdown list. If instead you want to find and pick one of the items, you'll have to loop through the options and set .selected true. If you know the index of the selected item, you can just set the .selected property to true directly.