I have a report which contains 4 prompts. These prompts are located on the actual report page. This is a report created against the metrics studio package.
prompt 1 is strategie and always needs to be selected. prompt 2: is a scorecard prompt
Prompt 1 and 2 are required.
Prompt 3 and 4 are placed in a conditional block and dependant on what is selected in prompt 2: prompt 3 or 4 will be shown.
Prompt 3 and 4 are optional. These are a supposed to show a subset of scorecards. (Basically I am trying to figure out a way to use cascading prompt functionality for scorecards.)
This all works fine. Until the user wants to change his selection for prompt 2. Cognos does NOT clear previously made selections for prompt 3 (for example). So the report will not show the new selection for prompt 2 but will still show the old selection for prompt 3.
In order to get around this, I wanted to use some javascript to clear the prompts. I admit, I avoid javascript like the plague in Cognos, so I am not very experienced at it. I did try to find a solution and it came up with some suggestions but these cleared all the prompts I just want to be able to clear prompts 3 and 4 not all of them.
i have found this snippet which works pretty well but unfortunately it clears all the prompt values:
<script type="text/javascript">
var oCR = cognos.Report.getReport("_THIS_");
function clearAllValues() {
var aControls = oCR.prompt.getControls();
for (var i = 0; i < aControls.length; i++) {
aControls[i].clearValues();
}
}
oCR.onload = clearAllValues();
</script>
A second example I found, which seemed closer to what I wanted to do was:
function clearRefresh() {
var oCR = cognos.Report.getReport("_THIS_");
var vNationality = oCR.prompt.getControlByName("Nationality");
var vDomicile = oCR.prompt.getControlByName("Domicile");
var vLevel = oCR.prompt.getControlByName("Level");
var vFeeCategory = oCR.prompt.getControlByName("Fee");
var vCourseStage = oCR.prompt.getControlByName("CourseStage");
vNationality.clearValues();
vDomicile.clearValues();
vLevel.clearValues();
vFeeCategory.clearValues();
vCourseStage.clearValues();
oCR.sendRequest (cognos.Report.Action.REPROMPT);
} </script>
<a href="JavaScript:clearRefresh()">Clear All & Refresh
I have tried to combine these two as follows:
<script type="text/javascript">
var oCR = cognos.Report.getReport("_THIS_");
function clearValues() {
var vVPE = oCR.prompt.getControlByName("VPE");
var vSPEC = oCR.prompt.getControlByName("SPEC");
vVPE.clearValues();
vSPEC.clearValues();
}
oCR.onload = clearValues();
</script>
I have found many examples on how to clear ALL the selected prompts within a report but have not found any that allow for a single deselect of a prompt.
I have tried to modify my prompts 3 and 4 to be multiselect prompts so the users could just click the default deselect button but - yeah.... the users did not want that.
If there is a smarter way to design my report, please do let me know.