A common request we’ve seen from several customers, is the desire to be able to share prompt answers, for several reports. The idea is that they have an application which will display several Cognos reports, all of which share a common set of prompts. (“Application”, in this case, could mean a C#/Java client, a SharePoint page, a web page, etc.) A common use of this pattern, is to establish a context that the application user is interested in (such as sales region, and a date range), and to use this context as prompt/filters on all subsequent reporting. Instead of prompting the user several times for each report, the application prompts just once, and then uses these prompt answers to set the context, for subsequent running of all the reports. The CMS resources promptPage and promptAnswers support this pattern, by allowing the application writer to decouple the prompting for a report, from the running of the report(s).
Cognos provides a powerful prompting facility, which include features such as calendar controls, drop down selections, cascading prompts, etc. As well, report authors can further design and customize the prompt pages for their reports. CMS provides access to these prompt pages, independent of actually running the reports, through the promptPage resource. As an example, to get the prompt page for a report at Public Folders > Reports > Inventory Report, the REST URL request for this resource is:
This resource returns an XML document with two elements:
- promptID: This is an id, to be used in requesting the collected prompt answers
- url: This is the address of the HTML prompt page
Here’s an example of this prompt page XML document:
The application can now open a browser window (or IFRAME) with the source set to this HTML prompt page url, to ask the user for the prompt response (without immediately having to run the report(s)).
Once the user has specified all the prompt values, and clicked the “Finish” button, the chosen prompt answers are saved on the Cognos server. To retrieve these answers, the application can use the CMS promptAnswers resource (and the promptID from the prompt page XML document):
(Note: the id after “conversationID/” for this resource, is the “promptID” element returned in the prompt page XML document). The promptAnswers resource is an XML document describing all the prompt answers selected:
The application can then use these prompt answers, when running the report, by providing the “xmlData” query parameter, which is set to the value of this promptAnswer XML, on the request:
Besides the Inventory Report, for which these prompts were originally collected, these same prompt answers can be used for running any of the other reports with the same prompts (using the xmlData query parameter). For example, for the Sales Report:
The decoupled set of prompt-related resources available from CMS, allow flexibility to fit many different application requirements related to prompting. Other variants of this idea include:
- Saving the prompt values in the client (to be used for a future session)
- Instead of using the Cognos prompt controls, a client renders its own prompt controls and collects prompts answers
- Instead of directly prompting the user, prompt answers could come from other parts of the applications
The CMS samples which are included in the Cognos SDK installation, include examples of working with promptPage and promptAnswer resources.