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 auto-submit doesnt work from cognos portal

Started by Krexx, 29 Apr 2020 03:06:28 AM

Previous topic - Next topic

Krexx

Hello together, i am facing following problem. I have an report that contains three date prompts where i am using javascript to select a specific value.

I also use another script to auto-submit the prompt page. I am using following code:

script type="text/javascript"


var fx = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);

if (fx)
{

  if (fx.elements["cv.id"].value == "RS")
  {
     setTimeout('oCVRS.promptAction(\'finish\')', 10);
  }else{
    setTimeout('oCV_NS_.promptAction(\'finish\')', 10);
  }
}
script

When i run the report out of the report studio or press run from the cognos portal then it works perfectly. But if i trigger the report by an specific time or try to send it via E-mail it doesnt work.

Has anyone faced similiar problems and knows how to solve this or knows an workaround?

Thanks in advance

CognosPaul

JavaScript is only ever processed when the user runs the report. Batch runs, when scheduled or sent via emails, bypass the prompt page entirely.

The only way around this would be to define the filters in such a way that running the report without using the prompt page will default to the correct dates. There are a few ways of doing this, but it's heavily dependent on what version of Cognos you're running.

To start, first examine the filters you're currently using. Does it look like this?

[Namespace].[Dimension].[Date] = ?Selected Date?

If so, that is a prompt alias. Prompt aliases are fairly basic. They don't allow for any special features found in prompt macros, such as default values.

Let's change that to

[Namespace].[Dimension].[Date] = #prompt('Selected Date','date',sq(timestampMask(_add_days($current_timestamp,-1),'yyyy-mm-dd')))#

If a value isn't passed to the 'Selected Date' parameter, it will default to yesterday's date.

Since you're on Cognos 10 (at least based on the forum you posted in), you can also use a parameter map lookup as the default value. In the framework package set up a query that returns the date you want and an item with a static 1. Set that as the source of a parameter map, with the 1 as the key and the date as the value. In the filter you could then use:

[Namespace].[Dimension].[Date] = #prompt('Selected Date','date',sq($DateLookup{1}))#