Hi all, new to the group, though I often use this wonderful site for help with my Cognos questions! Thanks!
I have a client requirement that I haven't been able to find a solution for.
I have a date range prompt. I need to insert a pop up warning or prevent a user from selecting "Finish" with pop up when the user selects 365 days worth of data. I know Javascript can be inserted into HTML tags. Can anyone help with finding the best method for this?
I think I need to count the number of days between dates selected and then pop up or restrict if x=365. How do I reference the date range on a prompt? Should I use two single date prompts and then count the days between those? Or is there an easier method that I am overlooking? It seems to me that this is not a crazy or unheard of ask.
two things immediately pop out of my head...
1. do not pop up a warning. use the restrict option... if days >= 365 then 364 else days
2. create two prompts for date range, start_date and end_date. then cascade them. filter end date so that the options available will not be more then 365 days from the start_date chosen
Quote from: Francis aka khayman on 10 Oct 2019 12:54:05 PM
1. do not pop up a warning. use the restrict option... if days >= 365 then 364 else days
2. create two prompts for date range, start_date and end_date. then cascade them. filter end date so that the options available will not be more then 365 days from the start_date chosen
Thanks for the response!
I tried the first option but seem to be having some syntax issues with it. It is not letting me use the days function in a filter.
For the second option you suggested, date prompts do not allow for cascading.
hold on.
1. you are using _add_days function aren't you?
2. i have to agree this is not feasible. you can use normal prompt and convert to date but that would be too much work...
I tried the days function for DB2, _days_between, and _add_days. The _add_days will not work because this simply adds a day to the date selected.
Still trying to find a feasible solution to this.
math 101... if you add a negative number, it will actually result to subtraction.
Quote from: Magdalina08 on 11 Oct 2019 11:14:35 AM
I tried the days function for DB2, _days_between, and _add_days. The _add_days will not work because this simply adds a day to the date selected.
Still trying to find a feasible solution to this.
Quote from: Francis aka khayman on 11 Oct 2019 11:45:33 AM
math 101... if you add a negative number, it will actually result to subtraction.
Not sure I am following here. This is the description from Cognos on the _add_days function:
_add_days ( date_expression, integer_expression )
Returns the date or datetime, depending on the format of "date_expression", that results from adding "integer_expression" days to "date_expression".
Example: _add_days ( 2002-04-30 , 1 )
Result: 2002-05-01
Example: _add_days ( 2002-04-30 12:10:10.000, 1 )
Result: 2002-05-01 12:10:10.000
Example: _add_days ( 2002-04-30 00:00:00.000, 1/24 )
Note that the second argument is not a whole number. This is supported by some database technologies and increments the time portion.
Result: 2002-04-30 01:00:00.000
can you try what the result of this is?
_add_days(2002-04-30,-365)
** you may have to provide a correct date value
This just gave me a date that was 365 days less than my date.
(2019-01-01, -365) = 2018-01-01
then can you not filter your data where [Date of my data] > _add_days([Start Date from Prompt],-365)
It looks like there is a sample that may be similar on the CA blog site.
https://community.ibm.com/community/user/businessanalytics/blogs/steven-macko/2018/09/10/javascript-samples-for-ibm-cognos-analytics?CommunityKey=6b10df83-0b3c-4f92-8b1f-1fd80d0e7e58&tab=recentcommunityblogsdashboard
Quote from: dougp on 11 Oct 2019 04:16:05 PM
It looks like there is a sample that may be similar on the CA blog site.
https://community.ibm.com/community/user/businessanalytics/blogs/steven-macko/2018/09/10/javascript-samples-for-ibm-cognos-analytics?CommunityKey=6b10df83-0b3c-4f92-8b1f-1fd80d0e7e58&tab=recentcommunityblogsdashboard
That is super helpful for Cognos 11. Do you know if this works in 10.2, if there is exisiting script for that version, or if this script will work? I haven't used JS in Cognos before, so this would be a first for me and I've read it's not very compatible in versions below 11. We have version 11 so I was able to pull the files, but the client isn't ready to move that way yet.
I did find this for version 10.2. Trying to get the samples imported now and will inform how it goes.
https://www.ibm.com/support/knowledgecenter/SSEP7J_10.2.1/com.ibm.swg.ba.cognos.ug_cr_rptstd.10.2.1.1.doc/c_rs_smples_prompt_api.html