COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: raja_krp on 15 Jun 2017 12:39:28 AM

Title: Clear prompt values on report rerun using Javascript
Post by: raja_krp on 15 Jun 2017 12:39:28 AM
Hello Team,

I have two prompts, one Radio button prompt and a Textbox prompt.

I need steps to clear the prompt values on report rerun. I am able to find the following script on line and added a HTML item with that code after the prompts in the prompt page but the prompt values are not getting cleared. Can you please let me know the steps and if required suggest me the changes to the script.


<script type="text/javascript">
   function clearAllValues() {
      var oCR = cognos.Report.getReport("_THIS_");
      var aControls = oCR.prompt.getControls();
      for (var i = 0; i < aControls.length; i++) {
            aControls.clearValues();
      }
   }
</script>


<script>
window.onLoad=clearAllValues;
</script>


Thanks
Title: Re: Clear prompt values on report rerun using Javascript
Post by: Stepharia on 16 Jun 2017 12:35:07 AM
The following works for me.
<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>