If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Java script for search and select default

Started by darners, 30 Jan 2018 04:19:02 AM

Previous topic - Next topic

darners

Hi

Can anyone advise on how to set the Default of for Search and Select prompts within Cognos 11

Within Cognos 10 I used CognosPaul Script

<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>

Thanks in advance

darners69

I have made some progress on this (sort of)

If I use the following Javascript (I have scavenged this from other posts) I no longer get an error, but at the same time the option still doesn't change

If anyone has any ideas on this it would be gratefully received as I just seem to be going round in circles

define( ["jquery"], function(  ) {
"use strict";


function SnSDefault()
{
};

SnSDefault.prototype.initialize = function( oControlHost, fnDoneInitializing )
{
    var o = oControlHost.configuration
   , prmptCtrl = oControlHost.page.getControlByName(o["promptName"])
   , prmptElmTgNm = oControlHost.page.getElementsByTagName(o["input"])
    , optNo = 3  // 1 = Starts with any ... (default) / 2 = Starts with first ... / 3 = Contains any ... / 4 = Contains all ...
   , optCnt = 0
   , myInput = prmptElmTgNm;
   for(var i=0;i<myInput.length;i++){
      if(myInput.type=='text') {
         if(myInput.value>''){
            return;}}
      if(myInput.type=='radio') optCnt++;
      if(optCnt==optNo) myInput[optNo].click();
   }

    fnDoneInitializing();

}

return SnSDefault;
});

rockytopmark

Quote from: darners on 30 Jan 2018 04:19:02 AM
Hi

Can anyone advise on how to set the Default of for Search and Select prompts within Cognos 11

Within Cognos 10 I used CognosPaul Script

<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>

Thanks in advance

This code still works in Cognos Analytics.
You may need to add a DIV tag (using an HTML Item) to before the prompt control, and close the DIV at the start of your javascript to change the default

From a layout perspective; HtmlItem1  thePromptControl  HtmlItem2

HTMLItem1:
<div id="promptName">

.... the promptName search and select prompt control....

HTMLItem2:
</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('promptName').getElementsByTagName('input')[4].click();
</script>

darners69

Thanks for the reply but unfortunately this doesn't work if 'Interactivity' is set to yes on the report

Which we need

gau

we have the same situation. someone arleady found an solution for setting the default value in interactive mode ?
thanks in advance

CognosPaul

#5
This post has inspired me! You get to be the guinea pig today.

Run the report attached to this article and tell me if it works for you.