Search code examples
javascriptcognoscognos-10

Cognos 10 Prompt API Clear Selections and Refresh Page


I'm hoping someone can steer me in the right direction as I'm very new to Javascript and am probably missing something obvious or misunderstanding a key concept.

I've written the following which works fine

<script type="text/javascript">

function clearAllValuesDemographic() {

var oCR = cognos.Report.getReport("_THIS_");

var vNationality = oCR.prompt.getControlByName("Nationality"); var vDomicile = oCR.prompt.getControlByName("Domicile"); var vLevel = oCR.prompt.getControlByName("Level"); var vFeeCategory = oCR.prompt.getControlByName("Fee"); var vCourseStage = oCR.prompt.getControlByName("CourseStage");

vNationality.clearValues(); vDomicile.clearValues(); vLevel.clearValues(); vFeeCategory.clearValues(); vCourseStage.clearValues(); } </script>

<a href="JavaScript:clearAllValuesDemographic()">Clear All Selections

I'm trying to create a variation of this which clears the values and also resubmits the page.

I've been trying to get the page refresh to work in isolation but haven't had any luck. This is what I've been trying:

<script type="text/javascript">

function refreshPage () {

var report = cognos.Report.getReport("_THIS_"); report.sendRequest (cognos.Report.Action.REPROMPT);

</script>

<a href="JavaScript:refreshPage()">Test

I've also tried adapting the Prompt API - Auto refresh a report in the Browser / Web with a timed interval method at http://www-01.ibm.com/support/docview.wss?uid=swg21646893

by taking out the interval but didn't have any luck connecting this to the link (non-working code below):

<script> (function(global){

var ocr = cognos.Report.getReport("_THIS_"); function sendPRMT_Request(eAction) { ocr.sendRequest(eAction); } function sendFinishRequest() { sendPRMT_Request(cognos.Report.Action.FINISH); }

})(this); </script>

<a href="JavaScript:function(global)">Test

Can anyone show me what I'm doing wrong or point me in the right direction of a method for doing this?

Cheers

James


Solution

  • and just to follow up in case it's useful for anyone: The overall expected behaviour was to clear prompts and refresh the page. The final code I used is:

    function clearRefresh() {
    
    var oCR = cognos.Report.getReport("_THIS_");
    
    var vNationality = oCR.prompt.getControlByName("Nationality");
    var vDomicile = oCR.prompt.getControlByName("Domicile");
    var vLevel = oCR.prompt.getControlByName("Level");
    var vFeeCategory = oCR.prompt.getControlByName("Fee");
    var vCourseStage = oCR.prompt.getControlByName("CourseStage");
    
    
    vNationality.clearValues();
    vDomicile.clearValues();
    vLevel.clearValues();
    vFeeCategory.clearValues();
    vCourseStage.clearValues();
    
    oCR.sendRequest (cognos.Report.Action.REPROMPT);
    
    } </script>
    
    <a href="JavaScript:clearRefresh()">Clear All & Refresh