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

StackOverflow https://stackoverflow.com/questions/14441522

  •  17-01-2022
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Regular Prompt Used in Data items calculations/logic always become required regardless because the data item in query must be presented and is not optional as in presentation items so the calculation has to resolve. Like the other poster stated in comes prompt macros ## which truely serves in my opinion 2 real-world purposes and argueable some others that we won't talk about.

  1. A poor mans search/replace substitution in queries before they are submitted(handy in these situations).
  2. defaulting a parameter if missing which in 8.4 is freaking darn near impossible to do especially in a data item.
  3. In MDX queries prompt macros are awesome because of #1 Hard Search and Replace in queries without the native Cognos prompt issues that get in the way sometimes.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top