COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: kenrisen on 01 Jul 2011 10:12:26 AM

Title: Javascript Not working in Cognos viewer(Portlet), But Working in Report studio
Post by: kenrisen on 01 Jul 2011 10:12:26 AM
Hi all cognos gurus,
Here is my issue....
I am trying to set first data as a default values for my prompt. I used JavaScript for that which worked perfectly fine, when I run report through report studio. But when I tried to run that report through Cognos Viewer Portlet, it seems, JavaScript is not working.
Cognos version 10.1
JavaScript I am using..

<script type="text/javascript">
function init()
{
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (fW)
fW._oLstChoicesUser.options[2].selected = true;
canSubmitPrompt();
}
init();
</script>

"User" is my value prompt name
how to solve this?
btw i'm a javascript newbie.
Title: Re: Javascript Not working in Cognos viewer(Portlet), But Working in Report studio
Post by: kenrisen on 04 Jul 2011 07:11:30 AM
i solve this problem..
for everyone, you can use this script

<script language="javascript">
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}
fW._oLstChoicesUser.options[2].selected = true;
var preFix = "";
if (fW.elements["cv.id"])
{
   preFix = fW.elements["cv.id"].value;
}
</script>