If you are unable to create a new account, please email support@bspsoftware.com

 

How to prevent a report from running unless user has sel. >1 optional prompt?

Started by psrpsrpsr, 23 Mar 2017 10:21:55 AM

Previous topic - Next topic

psrpsrpsr

Sorry about the title, ran out of characters.

I have a report that returns a huge number of rows. I have a few prompts (let's say zip code, state, region, and time zone) for which users can select their desired output.

I don't want to make these prompts required, because then users would be forced to select a value in each prompt - that doesn't make sense from a usability standpoint.

If I make them all optional, then the user can execute the report without any filters and return X million rows (hypothetically).

Is there a way to prevent reports from running unless at least one value from any prompt has been selected?

Thanks


BigChris

I imagine there is a way, but I can't think what it is from the top of my head. Another alternative would be to create a variable that checks for your parameters being "not missing" and then use that as a render variable.

psrpsrpsr

Can you explain how that render variable process would work? I'm not an expert in Cognos, so if you could make it step-by-step, that'd be very helpful. Thanks!

New_Guy

Hi,
As Big Chris said,

The easiest method is to leave the filters as optional with default setting for the prompts and create a boolean variable like the below and assign it to the data container like list or crosstab etc..
ParamDisplayValue('Parameter1') is not null or
ParamDisplayValue('Parameter2') is not null or
ParamDisplayValue('Parameter3') is not null or
ParamDisplayValue('Parameter4') is not null

if the user doesnt select any of the 4 prompts and hits enter or finish button they will see an empty page.
Or
you can display a text saying 'please go back to the prompt page and select at least one prompt' by using the same variable for styling(box type none).

But before all this place a text saying 'select at least one prompt if you dont want to see a white page' on the prompt page itself.

Google for "disable finish button in cognos" and you will see lot of discussions around it.

Good luck
New_Guy




CognosPaul

Prompt API would be good for this. Something like:


var paulScripts = {},  oCR = cognos.Report.getReport( "_THIS_" ), prmpts = ['promptName1','promptName2','promptName3'];

paulScripts.getControl = function (promptName) {
  return oCR.prompt.getControlByName(promptName);
}

for(var i = 0, i<prmpts.length;++i){
paulScripts.getControl(prmpts[i]).setValidator(function(){
  var hasdata = 0;
  for(var j=0;j<prmpts.length;++j){
    if(paulScripts.getControl(prmpts[j]).getValues().length) hasdata++;
  }
  if(hasdata) return true;
  return false;
})
}


I haven't tested it, so it probably has some errors in it. But give it a try.