Professional Documents
Culture Documents
Purpose
This technique uses JavaScript to allow a user to pass multiple values to an IBM Cognos 8
Report Studio textbox prompt.
Applicability
The technique in this document should only be used against relational data sources.
The technique identified in this document was validated using:
IBM Cognos 8.4.102.18-0 using the Go Sales (query) package shipped with the samples.
Back to top
Creating the Base Prompted Report
To create the base report
1. Open IBM Cognos 8 Report Studio against the Go Sales (query) package shipped with
the samples.
2. Select Create a New report or template
3. When prompted, select the List object.
4. From the left hand Insertable Objects pane, drag Go Sales (query)\Sales
(query)\Branch\Branch code into the list.
Figure 1 IBM Cognos 8 Report Studio list report iwth Branch code as a column.
18. Within the Prompt page, highlight the Text box prompt by clicking on it.
19. Within the bottom left Properties pane, add a name of id2 to the Miscellaneous\Name
attribute.
Figure 6 IBM Cognos 8 Report Studio Prompt Page showing the textbox prompt
highlighted.
20. Within the Prompt page, highlight the Value prompt by clicking on it.
21. Within the bottom left Properties pane, add a name of id3 to the Miscellaneous\Name
attribute.
Back to top
Replacing the Finish Button using JavaScript
An easy way to validate prompt data before submitting it to the report is to replace the generated
Finish button with a JavaScript one. To do this:
1. At the bottom of the Prompt page, highlight the Finish button and delete it.
2. From the left hand Insertable objects pane, locate the HTML object.
3. Drag the HTML object to the same location of the previously deleted Finish button.
Figure 7 IBM Cognos 8 Report Studio Prompt page showing the HTML toolbox
4. Double click the previously added HTML Item and add the following code.
<input type="BUTTON" class="clsPromptButton" onClick="SplitText()" value="
Finish ">
5.
6. Click the OK button to commit the HTML code.
Back to top
Adding the JavaScript to Parse the Text Prompt Values
1. From the left hand Insertable objects pane, locate the HTML object.
2. Drag the HTML object to the right of the Value Prompt.
Figure 8 IBM Cognos 8 Report Studio Prompt page with an HTML item next to the
value prompt.
if(var2[i].value==text_array[numberofsplits])
//if the value from the text prompt is
//present in the value prompt select it
{
var2[i].selected=true;
}
}
numberofsplits++;
}
promptButtonFinish();
}
}
</script>
highlighted.
10. Re-run the report, and type the following string (without the quotes) into the text box.
"6 19 21"
11. Click the Finish button.
Figure 10 IBM Cognos 8 Report Viewer showing hte resultant list in HTML format.