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

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Clearing optional prompts in Report Studio

Started by fatnos, 29 May 2007 12:59:59 PM

Previous topic - Next topic

fatnos

Hi-

I have a report that has a prompt page with 3 required prompts.  User selects the prompts....report runs....everything is great.  The problem is, once the user is in the report that have six value prompts that they can select to cut the report.  The prompts work fine once selected and the report is refreshed using a prompt button.  Where I am struggling is when the user re-runs the report using the "Run Report" button at the top of Report Studio.  When that button is clicked the user is presented with the prompt page again and re-selects the required prompts.  Problem is....the optional prompts stay on the new run of the report when ideally they are returned to blank (or null).

Does anyone have an idea on how to blank out the optional prompts when the report is re-run using the "Run Report" button??  The trick is I need the optional prompts to stay populated if the prompt button is clicked.....but returned to null if the "Run Report" button at the top is clicked.

If this involves JavaScript....please provide me with any examples you can.

TIA,
Chris

goose

create hidden value prompts on the prompt page for the optional parameters. After the page has loaded set the selectedIndex of the controls to 0 via javascript. You can get javascript from my reply to this post http://www.cognoise.com/community/index.php?topic=2306.0

1. Remember not to "hijack" the onload event  http://simonwillison.net/2004/May/26/addLoadEvent/

2. In your function you can use the below where myValuePrompt is the name of the value prompt control in RS Form.Control('myValuePrompt').selectedIndex = 0;






fatnos

Goose-

Thank you for the reply.  I need all the help I can get with JavaScript in C8.

I have this code in the report:

{
document.forms["formWarpRequest"].elements["_oLstChoicesSelect1"].selectedIndex = 0;
setTimeout('listBox<fieldname>.autoSubmit()', 100); }

My prompt is named Select1.  This clears out the prompt value....but doesn't take into account how the page was reloaded.  If I understand what you posted, the code you supplied to me fires when the report page is loaded from the prompt page....correct?  I am very limited in javascript.  Can you tack on to the code above with an example of how I can tie this to the prompt page?

I am understanding where you are going with this.....I just don't know how to implement it in jscript.

Thanks Again,
Chris

goose

No worries here whats you:

1. Keep this piece of javascript for future use its very handy (if you hardcode all the control names and cognos decide to change then you must go and change all your prompt pages that have javascript)


var Cognos = {
  Dropdown: '_oLstChoices',
  Textbox:  '_textEditBox'
}

var Form = {
  Control: function (name) {
    return document.getElementById(Cognos.Textbox + name)
      ||   document.getElementById(Cognos.Dropdown + name)
      ||   document.getElementById(name)
      ||   false;
  },
  addLoadEvent: function (func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
      window.onload = func;
    } else {
      window.onload = function() {
        oldonload();
        func();
      }
    }
  }
}


2. Automatically include this javascript in all your prompts by:

   2.1 create a js file for the above javascript and save it in a folder here <cognosinstalldir>\webcontent

        Mine is like this <cognosinstalldir>\webcontent\etc\etc.js

        You can run it through a tool to take extra spaces etc to reduce size

   2.2 modify a cognos file to include the js file

        Open file <cognosinstalldir>\templates\ps\prompting\p_include.xsl

        Search for <xsl:if test="//promptButton or //defaultPromptFooter or //selectValue or //textBox or //selectDate or //selectWithSearch or //selectWithTree or //selectTime or //selectInterval or //selectDateTime or //selectDataSourceSignon">

        Add a script element below this to include the js file mine is
       <script language="javascript" src="../etc/etc.js" type="text/JavaScript">//leave this comment here to assure we have an explicit end tag for script</script>

3. Save and close, bounce cognos service

4. Now in your main prompt page add a HTML Item

5. paste the following into the source for the HTML Item

<script language='javascript'>
  Form.addLoadEvent(function() {
     Form.Control('Select1').selectedIndex=0;
  });
</script>


What will happen now is that when they rerun the report by clicking the play button the optional parameter will get reset.

Does this make sense?

Cheers