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

How to set default selection in value prompt?

Started by SGD, 11 Aug 2016 10:00:05 AM

Previous topic - Next topic

SGD

Hi All,

Technical details:
Report Studio (Cognos v10.2)
Datasource: SSIS Cube

Issue: We have value prompt which shows month values in '2016-01' format. In cube, periods from '2012-01' to '2020-12' are available hence whenever report runs it shows periods from '2012-01'due to default ascending order.

Requirement: We want to set default selection in the value prompt so that when report executes it will show last month's value in it. e.g. '2016-07' in this month and '2016-08' in next month automatically. We can't define ascending or descending order to values because last month's value is still far away from beginning and last month and user will any how need to scroll it to desired value.

Is it possible to set default selection to this value prompt to show last month's value in each new month?

Thanks in advance. Your help is highly appreciated.
Regards,
S.G.D.

Grayson_Basil

Sounds like you just need to use a query for the value prompt?

AnalyticsWithJay

You could make the prompt optional, and use a macro #prompt()# that specifies default selection. That way you would avoid having to use any kind of JavaScript to set dynamic defaults. Is that an option for you?

SGD

Quote from: CognoidJay on 11 Aug 2016 10:25:33 AM
You could make the prompt optional, and use a macro #prompt()# that specifies default selection. That way you would avoid having to use any kind of JavaScript to set dynamic defaults. Is that an option for you?

Thank you.

Value prompt can't be optional since that is the only prompt report has and has to be mandatory for the users to see monthly data.

Regards,
S.G.D.

SGD

Quote from: Grayson_Basil on 11 Aug 2016 10:11:12 AM
Sounds like you just need to use a query for the value prompt?

Thank you.

Value prompt already has query associated it and the data is populating from SSIS cube.
Regards,
S.G.D.

AnalyticsWithJay

Quote from: SGD on 11 Aug 2016 12:16:25 PM
Thank you.

Value prompt can't be optional since that is the only prompt report has and has to be mandatory for the users to see monthly data.

Is JavaScript an option then? Here's what I'd do:

Have an HTML item with <div id="MonthDefaultValue" style="display: none; visibility: hidden"> and a singleton with your value, and another HTML item with the closing </div> tag. Now, in your browser you have a hidden DIV that contains your default month value and is dynamic.

Then, there are lots of Knowledgebase articles that show you how to pre-select an option using JavaScript, and how to iterate through the values of a value prompt. You have to iterate through those values, and compare them to document.GetElementByID('MonthDefaultValue'). If the values are equal, then theSelect[0].options.selected=true;

Let me know if you need some help with the JS.

SGD

Quote from: CognoidJay on 11 Aug 2016 12:30:29 PM
Have an HTML item with <div id="MonthDefaultValue" style="display: none; visibility: hidden"> and a singleton with your value, and another HTML item with the closing </div> tag. Now, in your browser you have a hidden DIV that contains your default month value and is dynamic.

I understand from this is I need to a singleton between 2 HTML items and those HTML items should have suggested code. Singleton should have query associated with it which will have dynamically set default month's value. Right?

QuoteThen, there are lots of Knowledgebase articles that show you how to pre-select an option using JavaScript, and how to iterate through the values of a value prompt. You have to iterate through those values, and compare them to document.GetElementByID('MonthDefaultValue'). If the values are equal, then theSelect[0].options.selected=true;

This part I have not quite understood correctly. How 'MonthDefaultValue' can be passed to document.GetElementByID? Please elaborate.

QuoteLet me know if you need some help with the JS.
That would be really great. :)
Regards,
S.G.D.

AnalyticsWithJay

Here you go. I wrote and tested this using Cognos 10.1. Unfortunately I'm away from my desk where I have later versions of Cognos. The syntax might not work on later versions:

The first HTML item will have your DIV. I hard coded a month value for now during my testing, but you will use a singleton as stated in my earlier post:

<div id="MonthDefaultValue" style="display: none; visibility: hidden;">February</div>



<script type= "text/javascript">
myVar = setTimeout(setMonthValue, 1000);

function setMonthValue (){
var form = getFormWarpRequest();
var MonthList = form._oLstChoicesMonth;
var monthValue = document.getElementById('MonthDefaultValue').innerHTML;
var i = 0;
while (i <= MonthList.options.length)
{
if (MonthList.options[i].value == monthValue) {
MonthList.options[i].selected=true;
}

i++;
}
}
</script>


You'll notice I used a one second delay on the script. On my end it was executing before everything was rendered and I didn't have time to play around with document.onload.

Jay

MegaCogman

I am reading this post from CognoidJay and trying to apply to a post I did on August 16th ...Topic:   Drill Through - Use Parameter Passed From Source As The Default In The Target Prompt
( see link below).  Are you able to look a my post as well? 
  In my situation I am passing a parameter from one report to a second report using a drill thru.    I want the list prompt on the Target report to default to the value passed in the parameter.   I am able to get the target report to render according to the parameter passed to it.  but unable to get the list prompt to accept the parameter as default.   I want the list to remain so that I can make a different selection on the prompt if so desired.   I think I might need to use a Java script but not sure how ? 

http://www.cognoise.com/index.php/topic,31322.msg101988.html#msg101988


Thanks in advance for your help !