COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Annon on 13 Aug 2015 08:07:59 AM

Title: Page gets refreshed automatically while using Javascript
Post by: Annon on 13 Aug 2015 08:07:59 AM
Hi

I have added below Java script for default date prompt in prompt page.

<script language="javascript">
var dDate = new Date();
dDate.setMonth( dDate.getMonth() - 1);
pickerControlName.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>

It is working fine and giving me one month back from today's date. But I have a cascading prompt which refreshes the page and all the prompt values are going back . I am working in a Relational database.

How can avoid the prompt values going back ? Please let me know and its urgent.
Title: Re: Page gets refreshed automatically while using Javascript
Post by: CognosPaul on 13 Aug 2015 03:23:29 PM
The JavaScript is triggered by the page load. So every time the report refreshes, due to a cascading prompt for example, the JS will be reset. The solution here is to remove the JS after the page loads. Create a variable based on the date parameter:
paramValue('Date') is null

Use that as a render variable on the HTML item. When the page reloads, Cognos will populate the date param with the contents of the date prompt, the render variable will remove the HTML from the page when it loads.