banner-cognos_0.png

Navigate back to the prompt page in Cognos Report Studio

Tuesday, October 24, 2017

Most developers use the functionality of a prompt page while building reports in Cognos report studio (10.2.2 in this case). This offers a lot of advantages and it creates a smooth transition from prompts to the actual report. The only hassle I experienced was when you wanted to change the values for these prompts while you already ran the report. Yeah sure you can create layout component references, but in the case where you’re using a cascading prompt (my case) or any other fancy prompt, this can lead to unwanted situations!

 

I found that the easiest way to re-select the prompts was to basically navigate back to the prompt page and start over from there. Report studio allows for 2 ways to do this;

  1. Click the ‘Run the report’ button

  2. Create a ‘Back’ button by selecting the prompt button from the toolbox

But there is a third option, in case you wanted to create something more aesthetically!

If you prefer to have clickable text for example, that redirects you to the prompt page, try the following;  

 

1.    Add this script on your page in an HTML item (check this, this and this for more info)

<script>
var j = jQuery.noConflict();
j(document).ready(function(){
  j("#back2prompt").click(function(){
    window["oCV" + getFormWarpRequest().elements["cv.id"].value].promptAction('back');
  });
});
</script>

2.   Embed your clickable text in the following DIV tags, for example; 

<div id="back2prompt" style="cursor:pointer">

3.   If you prefer to use it on different elements, repeat these steps but use a different name for the DIV ID, for example "back2prompt2"

This is what my report page looks like (the last html item contains the script);

When running the report, the prompt page looks like this (pretty basic huh!);

The actual report shows;

Where you can see that the text between the DIV tags is clickable. Clicking it will rerun the report and navigate back to the prompt page, where the previously selected elements will remain highlighted!

 

Good luck!

-Peter-