Tuesday, March 02, 2010

Multiple select values in Cognos Report with store procedure


 

  1. Import the stored procedure in Framework Manager and set the parameters to:

    1st parameter = #prompt('param1')#

    2nd parameter = #prompt('param2')#

     
     

  2. Create a report in Report Studio with a report page calling the SP and a prompt page containing the multiple select value prompt

 
 

  1. Add a text box prompt object to the prompt page

 
 

  1. Set the following ID's for the objects on the prompt page:

    Multiple select value prompt ID = Preprocessing_ID1

    Textbox prompt ID = Postprocessing_ID1

     
     

  2. Add an HTML item with the following javascript to the report:

 
 

<script>

// IBM Cognos 8.3 specific

 
 

function assignParamValue()

{

// get the reference to the Cognos form

var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() :

document.forms["formWarpRequest"]);

 
 

var i, tmp;

tmp = "";

 
 

// get the handle for the 1st checkbox prompt - add div around them to distinguish

 
 

var prompt1 = document.getElementById('checkboxPrompt1');

 
 

// find all the children of the div of type checkboxes.

for (i=0; i < prompt1.childNodes.length; i++)

{

var node_list = prompt1.getElementsByTagName('input');

for (var i = 0; i < node_list.length; i++)

{

var node = node_list[i];

if (node.getAttribute('type') == 'checkbox')

{

if (node.checked)

{

if( tmp == "" )

{

tmp = node.value;

}

else

{

tmp = tmp + "," + node.value;

}

}

}

}

}

fW._textEditBoxPostprocessing_ID.value = tmp;

 
 

canSubmitPrompt();

promptButtonFinish();

}

</script>

  1. Add an HTML item before the checkbox with the contents of

    <div id="checkboxPrompt1">

    and add an HTML item right after the checkbox prompt with the contents of

    </div>

     
     

  2. Add a virtual "finish" button to call the javascript function before proceeding to the report itself by adding another HTML item and inserting the following code:

 
 

<input type="BUTTON" class="clsPromptButton" onClick="assignParamValue()"

value="Finish">

0 comments: