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

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

javascript question

Started by tupac_rd, 23 Sep 2011 11:08:41 AM

Previous topic - Next topic

tupac_rd

Hi Gurus,

For a text box prompt on the prompt page, we have javascript to set the previous month (for eg. 201108) if I run the report on any day in the month of September. The code used is below. The issue I am having is, the code works only when I run the report adhoc (Run Options -> View report). When I try to run the report in the background (Run Options -> Save report), the code doesn't work and the text box prompt is blank...

Can you please let me know what is missing in the code below, so that it works when running the report in the background...

<script>

var today = new Date();

var strVal = today.getMonth();

var strVal1 = today.getUTCFullYear();
if(strVal == 0)
(strVal1 = strVal1 - 1)
else (strVal1 = strVal1)


if(strVal < 10)
(strVal = "0" + strVal)
else (strVal = "" + strVal)

if(strVal == 0)
(strVal = "12")
else (strVal = strVal)


var strVal2  =  strVal1 + strVal;

getFormWarpRequest()._textEditBoxYYYYMM.value = strVal2;

</script>

kattaviz

Hi,

Try the following script.

<script>
var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);
// if it's undefined, check if it is running in a portlet
if ( !fW || fW == undefined)
{
fW = ( formWarpRequest_THIS_ ?formWarpRequest_THIS_ : formWarpRequest_NS_ );
}
var today = new Date();
var strVal = today.getMonth();
var strVal1 = today.getUTCFullYear();
if(strVal == 0)
(strVal1 = strVal1 - 1)
else (strVal1 = strVal1)
if(strVal < 10)
(strVal = "0" + strVal)
else (strVal = "" + strVal)
if(strVal == 0)
(strVal = "12")
else (strVal = strVal)
var strVal2  =  strVal1 + strVal;
fW_textEditBoxYYYYMM.value = strVal2;
</script>

thanks & regards
Satish Katta