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

Auto Submit Default Date for a Date Prompt

Started by Deepsy, 26 Jan 2012 10:28:21 PM

Previous topic - Next topic

Deepsy

I have two date prompts, a start date and a finish date on a prompt page. The start date needs to be yesterday's date and the finish date should be today's date. I have managed to get that working through the following javascript:

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

var months = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','A ug','Sep','Oct','Nov','Dec');

var ToTime=new Date();
var ToMonth=months[ToTime.getMonth()];
var ToDate= ToTime.getDate();
var ToYear=ToTime.getYear();
var ToDate = ToMonth + ' ' + ToDate + ', ' + ToYear;

var FromTime = ToTime;
FromTime.setDate(FromTime.getDate()-1);
var FromMonth=months[FromTime.getMonth()];
var FromDate= FromTime.getDate();
var FromYear=FromTime.getYear();
var FromDate = FromMonth + ' ' + FromDate + ', ' + FromYear;

pickerControlStartDate.setValue(FromDate);
pickerControlEndDate.setValue(ToDate);
}
DefaultDateSelection();
</script>

However, this report is part of a schedule and fails every time is run. The error message says dates were not specified.

Could anyone please advise where i'm going wrong? Is there an auto submit function that i'm missing out. I'm currently using Cognos 8.4.

Thanks!

Grim

You have to specify your prompt values when you schedule your report.
I'd create a separate report with hard coded prompts instead of javascript.

Depending on what DB vendor version your using you should be able to do "date - 1 day".
"Honorary Master of IBM Links"- MFGF
Certified IBM C8 & C10 Admin, Gamer, Geek and all around nice guy.
<-Applaud if my rant helped! 8)

tjohnson3050

I agree 100% with Grim

To expand just a bit - your java script fills in a default value on a prompt page.  With a schedule, when you set values for a prompt, it executes the prompt page once, and uses the value you select to satisfy the parameter.  That static value is then stored and used every time the scheduled report is executed.

As was suggested, remove the prompt from the report and replace it with logic.  You can use the following Cognos expression:

[your date field] between _add_days(current_date,-1) and current_date