I have 3 prompts. 1st Prompt contains the values A & B. On selecting A the remaining 2 prompts should get hidden and upon selecting B the 2 prompts should show. All the 3 prompts are mandatory. Can anyone help me achieve this scenario?
I'm going to assume that you already know how to conditionally hide and unhide elements and that you just want to know how to refresh a page without submitting it.
There are three solutions to your problem:
Method 1 - Reprompt Button
This is done by simply adding a prompt button to the report and setting the 'Type' property to 'Reprompt'. I don't recommend you use this method as requiring the user to click a reprompt button each time they change a prompt value is bad user experience.
Method 2 - JavaScript API
This method uses the Cognos-supported JavaScript API to reprompt the page whenever a value prompt changes value. Note that the API is only available in version 10.2 and later.
<script>
var report = cognos.Report.getReport('_THIS_');
var valuePrompt = report.prompt.getControlByName('valuePrompt');
var currentValues = (valuePrompt.getValues().length == 0) ? [{'use':''}] : valuePrompt.getValues();
valuePrompt.setValidator(validateValuePrompt);
function validateValuePrompt(values) {
if (values && values.length > 0) {
if (values[0].use != currentValues[0].use) {
currentValues = values;
report.sendRequest(cognos.Report.Action.REPROMPT);
}
} else {
currentValues = [{'use':''}];
}
return true;
}
</script>
The code is optimized so that the reprompt action only happens when the prompt is changed to a new value. This prevents multiple reprompts whenever the system checks the prompts for validity, which can happen quite often.
Method 3 - Hidden Dependent Prompt
This technique uses a hidden value prompt to trick Cognos into reprompting the page on every value prompt change by tying the prompt to a dummy value prompt using the cascading prompt functionality.
Whenever you change the value prompt, the page will reprompt in order to refresh the hidden prompt.