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

Javascript for value prompt not working in cognos viewer (portlet)

Started by arnoud, 23 Jul 2015 07:57:24 AM

Previous topic - Next topic

arnoud

Hello ,

I have two java script to automatically select the first value from a check prompt. The second script automatically submits the prompt page, so the value selected is executed within the report.
The problem occurs when i connect this report to a Cognos viewer.

For some reason the scripts are not executed correctly within this viewer.

So if some can help me solve the problem that would be great.

The first script is:

<div id="msgDiv" style="color:chocolate; font-size:18"></div>
<script>
   // Attach functions to an arbitrarily named object to mimic a namespace to ensure the name uniqueness
   var zxcv = {};

   // Get the required prompt.
   var oCR = cognos.Report.getReport("_THIS_");
   var oP = oCR.prompt.getControlByName("promptbudgethouder");

   // Get the values and isolate the first value.
   var allValues = oP.getValues(true);
   var firstValue = allValues[0];

   // Set the prompt selection to the first value.
   oValues = [firstValue];
   oP.setValues(oValues);
</script>

The second script is:

<script type="text/javascript">

//get the form request
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);

if (fW)
{
  // if the report is running from reportStudio or the Portal objects are different
  if (fW.elements["cv.id"].value == "RS")
  {
     setTimeout('oCVRS.promptAction(\'Finish\')', 1000);
  }else{
    setTimeout('oCV_NS_.promptAction(\'Finish\')', 1000);
  }
}
</script>

regards,

Arnoud

Andrew Weiss

Arnoud,

If you put a button on the report to invoke the script and then push the button after the report loads does it work properly?  If so you'll need to set your code to execute after the document is loaded (ready).  Here's an example of how to do that using JQuery.

https://learn.jquery.com/using-jquery-core/document-ready/

-Andy
MetaManager makes administering IBM Cognos a breeze.  http://www.bspsoftware.com/MetaManager

arnoud

Hello Andy,

thank you for the answer. But when i put a button to invoke the script within the report it isn't working.
When i put in the second script within the report it is working, but then the report is refreshing every time, and that is not suppose to happen.

Regards,

Arnoud