My personal favourite solution for this type of (common) problem, is to have Index values in your Period data source in the data warehouse.
For example, you can add 4 columns to your Period table, with:
DAY_INDEX
WEEK_INDEX
MONTH_INDEX
YEAR_INDEX
These fields contain 0 for current day/week/month/year, -1 for previous, 1 for next, etc.
This allows you to create simple dropdown prompt boxes, that you can order, and display then the common label for the Period, but use the index as parameter value.
The great thing of such solution, is that this makes it very easy to schedule reports on previous/current week or month or day, a very common way to schedule reports in businesses.
The downside is that currently this solution isn't made possible on pure date selection prompts (via date promptbox) and when you look at the assigned prompts in a scheduled report, Cognos always displays the label, which of course gets updated every week. So if you schedule in January a monthly report and set the report to use -1 as parameter for the month, then the scheduled report will show as prompt parameter in the UI a label with December. 2 months later, the report will run for February, but a user looking at the schedule parameters, will still see "December" (although this is just the incorrect label for the correct setting of -1).
Hope that's clear.
I used to be good at creating Javascript solutions for this kind of problems, but since the Javascripts are now stored not in the report but on the server, it's a bit more work trying to prep such a change. I personally now try to avoid it, as this creates risks thus more time in test/development for future releases.
Kind regards,
Joeri
------------------------------
Joeri Willems
------------------------------
Original Message:
Sent: Fri April 29, 2022 07:30 AM
From: P S
Subject: Select Year-Month in prompt Page
Hi Guys,
I need help in selecting the current year and month as default(Eg: 2022-02) on the prompt page using JS.
I' am displaying Year-Month in values prompt like:
2022-04
2022-03
2022-02 etc
It has some junk data like 2105-05 in the values list so, I' am unable to use this script to select current month
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (fW)
{
fW._oLstChoicesCurrentPeriodYear.options[3].selected = true;
listBoxCurrentPeriodYear.checkData();
Data Item "Year-Month" is not in the Date data type,
It is in varchar :- convert(varchar(7), [Date], 126)
so it's difficult to set the current month as default.
Needed JS script to select the current year and month, Help me to find the solution.
Thanks!
------------------------------
P S
------------------------------
#CognosAnalyticswithWatson