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

 

cognos10.1.1 : Unable to change default values in select and search promptusing

Started by katdbc, 27 Jan 2014 03:44:02 PM

Previous topic - Next topic

katdbc

   

I am using cognos 10.1.1 and db2.

I know this is a repetitive question but I havent found a javascript which would change the default option in a select and search prompt in cognos 10.1.1

Any suggestion would be greatly helpful.



I tried a simple JS to un check the "Case Insensitive" but it doesn't seems to be working. Not sure why.



<script LANGUAGE="JavaScript">
<!-
var fw = getFormWarpRequest();
var dropdown=fw._oLstChoicesID;
dropdown.getElementById("swsCaseInsensitive").checked=false;
//->

</script>



charon

hello kat,

take a look at this blog entry of the great cognos blog of cognospaul.
http://cognospaul.com/2012/11/25/quickie-changing-default-option-in-a-select-and-search-prompt/
i have tried this on my own on cognos 10.1.1 and it works like a charm.

gl and cheerz :P

katdbc

Hi charon,

I have already tried those JS from Cognospaul. But it doesnt seems to be working.

I have attached the sample report spec in which I have tried the JS.

Please let me know whats woing wrong.

CognosPaul

Hi katdbc, I see the problem. You've put the HTML items and prompt in separate cells in the table. The HTML would essentially look like:

<table><tbody>
<tr><td><div id="mySnS"></td></tr>
<tr><td><prompt></td></tr>
<tr><td></div></td></tr>
</tbody></table>


XML elements can't span tags like that, so the browser is automatically closing that div inside the cell. The HTML should look like:


<table><tbody>
<tr><td><div id="mySnS"><prompt></div></td></tr>
</tbody></table>


With the div immediately wrapping the prompt. The fix is to simply move the HTML items directly to the left and right of the prompt.

katdbc

Thank you so much Connospaul. Now it works like a charm.

I have another question for you. I also sent you an email which I got from your blog.

Is there a material or a book which I can buy from you to learn the Javascript basics for cognos or like a best practise to be followed.

CognosPaul

I'd start with learning the basics of JavaScript. Cognos doesn't always follow the best practices when it comes to writing JS, so learning from that isn't a good idea. Once you have the grounding, then start exploring the functionality of the API. One of the my tricks is the following function:

function getMethods(myObject) {
  var funcs=[];
  for(var name in myObject) {
    funcs.push(name)
  }
  return funcs.join(', ');
}


Try doing alert(getMethods(fW)), or alert(getMethods(fW._oLstChoices_myPrompt)) or any other object to see what you can play with. That's actually how I discovered invaluable methods like the getSelectedObjectsJsonContext function. That allows you to get the various attributes associated with a cell in a table or chart.

It's also worth going through the JS files that come with Cognos. Every function available can be found in them. I'm sure there are some gems that I haven't discovered yet.

katdbc

Thank you Cognospaul for your reply.

I have just started using JS in cognos. so it has been a rough ride since there is no actual point to start.

Are you talking about the COgnos Prompt API with 10.2 ?

regarding the JS files which comes with cognos, which version of cognos does it come with ? currently we have cognos 10.1.1  and does it also comes with JS files ?

I would have to ask my cognos admin, if she can find that . is there any particular location to look at ?

katdbc

<code>
function getMethods(myObject) {
  var funcs=[];
  for(var name in myObject) {
    funcs.push(name)
  }
  return funcs.join(', ');
}
</code>

That was really useful.


CognosPaul

All versions of Cognos come with some sort of API. The prompt api is the first officially supported and documented one. The full api is internal use only and controls things like expanding tree prompts and doing drill through. There are hundreds of functions.

The reason the full api isn't supported is simply a matter of money. IBM doesn't have the support staff to support all the questions people would have about it. So historically its always been unsupported.