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

Date picker auto submit & set initial value

Started by Johnson, 16 May 2014 01:11:00 AM

Previous topic - Next topic

Johnson

Dears,
The requirement are:
1.   when first run the report, it will pass yesterday to run the report and show the value in the date box.
2.   user is able to change the date by selecting a special date on the panel . after that, the report will be run automatically with the new date and show the new date in the date box.
I made the attached report spec which is very simple.(no package needed, please use IE to run it). The problem are:
1.   In the subsequent running, the date box will be always filled with the initial value(yesterday). The issue is the page is refreshed, so, the javascript to set the 'yesterday' is executed. The solution I can think is to add a hidden item, when user input a new value, then will set the value to the hidden item. user can check the hidden item value before setting the 'yesterday'.

<span id="databox">
----COGNOS DATE PROMPT TOOLKIT
</span>
<script>
//value of yesterday
function subtractDay ()
{ var dtToday = new Date();
  var dtYesterday = new Date( dtToday - 86400000 );
// NOTE 86400000 = 24 hours * 60 (minutes per hour) * 60 (seconds per minute) * 1000 milliseconds per second)
var strYesterday = [dtYesterday.getUTCFullYear(), dtYesterday.
getMonth()+1, dtYesterday.getDate()].join("-");
return strYesterday;
}
function subtractTime ()
{
var Time = "17:00:00.000";
return Time;
}
function setDate(){
   pickerControlshipmentDate.setValue( subtractDay() );
   timePickershipmentDate.setValue( subtractTime() );
}
//-------date prompt value
var
databox=document.getElementById("databox");
var
datainput=databox.getElementsByTagName("input");
var
datavalue=datainput[2].value;
datainput[2].onpropertychange=tochange;
function
tochange(){
if(datavalue!=datainput[2].value){
promptAction('finish');
}
}
</script>
<body onload="setDate()">
</body>

Is there any way  to achieve this?