Question

I'm working Cognos v10.1 . I'm creating a report which contains 13 optional prompts. Since it is really hard to accumulate the same in a single page and all the prompts are optional, I'm trying to write a javascript code for check boxes. Based on the selection in the check boxes, I'd like to show the prompts. I've got the result but there is an issue with the prompt. The page is getting refreshed before I select some values in any prompt which I've chosen. How to prevent the page refresh? Could you please suggest a solution. Thanks in advance.

Was it helpful?

Solution

If any of the Cognos prompts are cascading prompts (Properties->'Cascade Source' is anything other than blank) they will trigger a prompt page refresh after the parent prompt is chosen.

Also, any prompt with the Auto-Submit property set to 'Yes' will trigger a page submit after being selected (assuming all required prompts are filled) or will refresh your prompt page (if any required prompt is not yet filled).

Toddnappi's solution is one I have used successfully for situations like these and I highly recommend using it if possible. The Cognos javascript API is limited in 10.1, but predictable. There is no reason you should not be able to make the solution work the way you are trying.

Keep in mind that the javascript API is greatly improved in 10.2, and may be worth looking into if you have alot of need for custom built javascript pages.

Edit: Just did a test where I did a hide/show of an optional prompt in a prompt page:

Prompt Page in Report Studio

The HTML Item before the hidden area:

<script>
function checkDisplayPeriod() {
    var chkBox = document.getElementById("checkBox1");
    var divPeriod = document.getElementById("divHidePeriodPrompt");
    if (chkBox.checked) {
        divPeriod.style.display = 'none';
    } else {
        divPeriod.style.display = 'block';
    }
} 
</script>
<input type="checkbox" id="checkBox1" onclick="checkDisplayPeriod()" />
<div id="divHidePeriodPrompt">

The code after the area:

</div>

Page when first loaded: Prompt Page Initially loaded

After clicking (no refresh): Prompt Page After Clicking

OTHER TIPS

I'd recommend working within the confines of Cognos rather than trying to custom write JS. You will inevitably bump into some of their built in functions which will lead to odd behavior which will have cross-version and potentially cross-browser issues.

Instead, why not 2 prompt pages:

  • Page 1: Checkbox prompts using Value Prompts set to checkbox. Tie each of these to a variable.
  • Page 2: Conditionally rendered prompts based on variables.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top