COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: lee on 30 Nov 2009 10:11:38 PM

Title: Defaulting date prompt to BLANK
Post by: lee on 30 Nov 2009 10:11:38 PM
Hi All,

I have a report with  2 date prompts. Both prompts are optional. While running the report the 2date prompts are automatically set to sysdate. I am unable to remove the default sysdate in date prompt . Can someone help me out. I am using cognos 8.4 version.

I saw some java script in cognoise site but it is not working me.

Could your provide me the steps to achive BLANK date prompt.

Thanks in Advance,

Lee
Title: Re: Defaulting date prompt to BLANK
Post by: CognosPaul on 01 Dec 2009 02:37:26 AM
Give the prompt a name, and add an HTML item directly after it:

<script language="javascript">
document.formWarpRequest.elements["txtDatePromptName"].value='';
</script>
Title: Re: Defaulting date prompt to BLANK
Post by: lee on 01 Dec 2009 10:35:49 PM
Thanks Paul
Title: Re: Defaulting date prompt to BLANK
Post by: engsonu on 12 Mar 2013 08:52:59 AM
Hi

I tried the same code
<script language="javascript">
document.formWarpRequest.elements["txtDatePromptName"].value='';
</script>
but still its showing current date.

Can you please help?
Title: Re: Defaulting date prompt to BLANK
Post by: CognosPaul on 12 Mar 2013 09:55:40 AM
The PromptName should be the name you give to the prompt object on the page. If you don't give it a name, it won't work.
Title: Re: Defaulting date prompt to BLANK
Post by: engsonu on 13 Mar 2013 12:39:59 AM
prompt name is "CTSDate"
and expression is

<script language="javascript">
document.formWarpRequest.elements["txtDateCTSDate"].value='';
</script>

is that right?
Title: Re: Defaulting date prompt to BLANK
Post by: CognosPaul on 13 Mar 2013 04:29:27 AM
It should be. What version of Cognos are you running?
Title: Re: Defaulting date prompt to BLANK
Post by: engsonu on 13 Mar 2013 05:10:09 AM
8.4.1
Title: Re: Defaulting date prompt to BLANK
Post by: engsonu on 13 Mar 2013 06:28:19 AM
Thanks PaulM ,It sort out now.I was using parameter name.
Title: Re: Defaulting date prompt to BLANK
Post by: ruffs on 22 Apr 2013 12:45:33 PM
This solution works great except that im noticing when user's are filling out the prompt page after selecting the dates, on the next prompt, if they search the db using '%' the dates disappear.  Any ideas why that happens?
Title: Re: Defaulting date prompt to BLANK
Post by: CognosPaul on 22 Apr 2013 12:52:12 PM
The reason that it's happening is that the script runs after the page is refreshed. So the user selects a date, then performs another action on the page which causes the page to be refreshed. The prompt loads, with the previously selected date, then the script is triggered, once again removing the date from the prompt.

The fix is simple. Create a Boolean variable, paramValue('Date') is null, then set that as the render variable on the HTML item.
Title: Re: Defaulting date prompt to BLANK
Post by: ruffs on 22 Apr 2013 03:08:09 PM
Paul, could you please possibly be a little more specific?  Not quite so simple for me :)
Title: Re: Defaulting date prompt to BLANK
Post by: CognosPaul on 22 Apr 2013 03:21:16 PM
You have an HTML item that contains the JavaScript to remove the value from the date prompt.

In RS, click on that HTML item. On the bottom left pane there is a row for Render Variable. Open that and create a new variable with the expression: ParamDisplayValue('Date') is not null
That's assuming that the parameter name for the Date prompt is Date.
Title: Re: Defaulting date prompt to BLANK
Post by: ruffs on 23 Apr 2013 08:06:12 AM
Sorry Paul, so i click on the html item.  In the properties I click render variable.  In the dropdown I chose 'new boolean variable' and assign it a generic name.  The report expression window appears I click the parameters button at the bottom and drag over my parameter and type in is not null afterwards so it reads - ParamDisplayValue('ActCreateStDt') is not null.  When I run the report now the current date is now populated which of course is what I want to avoid.  Can you please advise?
Title: Re: Defaulting date prompt to BLANK
Post by: CognosPaul on 23 Apr 2013 09:03:51 AM
Try is null instead of is not null, my mistake.
Title: Re: Defaulting date prompt to BLANK
Post by: ruffs on 23 Apr 2013 10:52:21 AM
I should have caught that but it works now Paul:)  Thank you very much for your help...
Title: Re: Defaulting date prompt to BLANK
Post by: wdv72 on 12 Apr 2016 06:59:07 AM
Hi Everyone,http://www.cognoise.com/Smileys/default/shocked.gif
I am also trying to default multiple dateprompts with default empty values. However, the javascript empties the prompts on the promptpage but also makes the prompts totally unusable.  ??? I have set names for each dateprompt and put that in separate scripts per prompt.

When I do fill in date values (from and to dates), the report ignores these and shows all data.

We are using Cognos 10.1.1

Hope you can help me.
Title: Re: Defaulting date prompt to BLANK
Post by: wdv72 on 18 Apr 2016 12:10:49 AM
Hi Guys (and girls of course  :D )

Figured it out myself. At first I used filters with a between functionality (date >=?prompt1? and date <=?prompt2?) in one filter.
I separated these and made 2 seaprate filters, which did the trick.

kr,