Setting the default search type in Cognos 11 interactive mode

The search prompts haven’t gone through many changes in Cognos since version 8. Despite many requests, changing the default search type (from starting However, one big whopping change is the popup element containing the search items is no longer inside the search control. Instead it’s hidden somewhere else on the page, with nothing tying it to the actual control.

This makes the old script useless, and finding that popup is incredibly difficult. In Cognos 11.1 the method for finding the popup is promptElement._FZH._9FF while in 11.0 it’s promptElement._REG._FZD. This obfuscation means we have to rely on trickery and shenanigans.

Look away now if you value your sanity

prmptElmLoop: //yes I'm using a label here. I'm not feeling at all defensive about it.
  for(var a in  $(prmptElm).find('.clsComboBox')[0]){
    if(typeof($(prmptElm).find('.clsComboBox')[0][a])=="object" ){ //if the object itself is an object...
      for(var b in $(prmptElm).find('.clsComboBox')[0][a]){ //...dig deeper.
        if($(prmptElm).find('.clsComboBox')[0][a][b].classList=="po_clsListView_dropdown po"){ //this identifies the actual popup element. 
          $($(prmptElm).find('.clsComboBox')[0][a][b]).find("tr:eq("+(opt-1)+")").trigger('mousedown'); //finds the correct table row and performs a mousedown. 
          break prmptElmLoop;
    else continue;


In order to find that options popup, we’re looping through the prompt element and examining each attached method. If it’s an object, we go deeper. Finally we’ll find a method that’s a pointer to the element (which we can identify using the class), and then it’s just a matter of triggering a mousedown event on the correct row.

In order to use it, you need to give the search prompt a name, like mySnS. The custom control needs to have the following configuration:

"promptName": "mySnS",
"option": 2,
"resizeOptions": true

That’s looking for the prompt name mySnS, selecting “Starts with the first keyword and contains all of the remaining keywords”, and then resizing the options list.

The options are as follows:
* 1 – Starts with any of these keywords * DEFAULT
* 2 – Starts with the first keyword and contains all of the remaining keywords
* 3 – Contains any of these keywords
* 4 – Contains all of these keywords

Important note! I’ve tested this on 11.0.5 and 11.1.0. I have no reason to think it won’t work on other C11 versions but I can’t promise it will continue working. Hopefully methods like this will be exposed with a consistent name in future versions.

The attached zip contains the report XML and the JavaScript. (7361 downloads)