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

setValues() and addValues() methods not working | Prompt API

Started by Hardik Binnani, 20 Jul 2020 01:50:27 AM

Previous topic - Next topic

Hardik Binnani

Hi All,

I am trying to populate the value prompt in my report using java script. I am using setValues() and addValues() methods to cater this.

Here is what I have done.

Created two value prompts:
1. kkprompt (static choices = 'use': mango, 'display': apple). It has only one static choice
2. defaultselprompt. This is an empty prompt. No values here.

What I am trying to do is to copy the first value of 'kkprompt' prompt and put it in 'defaultselprompt'.

The JS which I used is:
<,SCRIPT,>
function ,setPromptDefaultVal(),{
try
{
   var oCR = cognos.Report.getReport(,_THIS_,);
   
   var myPrompt = oCR.prompt.getControlByName('kkprompt');
   var kkValues = myPrompt.getValues(true);
   var aikaPrompt = oCR.prompt.getControlByName('defaultselprompt');
   oValues = [{"use": kkValues[0].use, "display": kkValues[0].display}];
   aikaPrompt.setValues( oValues );

}
catch(err)
{
alert,(err);
}
}
,setPromptDefaultVal(),;
<,/SCRIPT,

But after this, the second prompt remains empty. Sort of setValues() isn't working. I trued addValues() too but it didn't work as well.

Please suggest how can this work?
Thank you,
Hardik Binnani

dougp

To use JavaScript in inline HTML, you should have the Run with full interactivity property set to No.

Leaving the Run with full interactivity property set to Yes is preferred.  That would require you to use RequireJS as in IBM's report script docs. (https://public.dhe.ibm.com/software/data/sw-library/cognos/mobile/scriptable_reports/index.html)

https://requirejs.org/ has some good documentation and sample code to get you started.  You can also learn a lot from the JavaScript samples that come with Cognos and from the Cognos documentation.  (https://www.ibm.com/support/knowledgecenter/en/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.cbi.doc/welcome.html)