I’ve been somewhat negligent in responding to the comments lately. One of the most common questions appears to be how to change the default option in a select and search prompt.
The following should work for all versions of Cognos.
Put an HTML item before the prompt, with the expression:
<div id="mySnS">
Now put another HTML item after the prompt with the expression:
</div> <script> /* Select and search options * 2 - Starts with any of these keywords * DEFAULT * 3 - Starts with the first keyword and contains all of the remaining keywords * 4 - Contains any of these keywords * 5 - Contains all of these keywords */ document.getElementById('mySnS').getElementsByTagName('input')[5].click(); </script>
The script will locate the mySnS element that surrounds the prompt, generate an array of the input tags, and click() on the one specified. In the example, 5 is selected so it will click on the sixth element (0 based array).
Going through the Cognos JavaScript files, it looks like there is supposed to be a function in the new Prompt API that would let you do it in an easier manner, unfortunately it appears to be an incomplete function, maybe it will be released in the new fixpack.
In theory, you should be able to do something like the following:
var acme = {}; acme.getControl = function(promptName) { var ocr = cognos.Report.getReport("_THIS_"); return ocr.prompt.getControlByName(promptName); }; acme.getControl('mySnS2').setProperty( "caseInsensitive", false); acme.getControl('mySnS2').setProperty( "searchType", "containsAny");
But, as I said, the function doesn’t appear to be complete in this version. Use the other method for now.