In cognos, could we avoid an optional prompt asking a value when its parameter is used in a data item in a query?

arunpandiyarajhen picture arunpandiyarajhen · Jan 21, 2013 · Viewed 12.2k times · Source

Actually, I'm working in Cognos 10.1 report studio. In my report, I have two prompts, one is optional and another prompt is required. I've used both the prompt parameters inside the data item for some condition. So, the optional prompt has also turned to required. What should we do to avoid this?

Answer

arunpandiyarajhen picture arunpandiyarajhen · Jan 21, 2013

We can use #prompt()# for this. Usually, #prompt()# is used to deliberately force the parameter to hold some value. Instead of using the parameter directly, we should use the #prompt()#.

For example,

Suppose, ?Parameter1? is used in a data item and it holds a integer value, replace it with a #prompt()# like this #prompt('Parameter1','integer')#.

Suppose, if the condition is like

if(?Parameter1? is not null)
{  
   statement; 
}

it should be,

if(#prompt('Parameter1','integer')# is not null) 
{
   statement; 
}

If we use #prompt()#, we can use the parameter inside the data item, without affecting the prompt's usage.