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
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;
});
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>
Thanks for the reply but unfortunately this doesn't work if 'Interactivity' is set to yes on the report
Which we need
we have the same situation. someone arleady found an solution for setting the default value in interactive mode ?
thanks in advance
This post has inspired me! You get to be the guinea pig today.
Run the report attached to this article (http://cognospaul.com/2018/11/25/setting-default-search-type-cognos-11-interactive-mode/) and tell me if it works for you.