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

 

2 differents default values in a tree prompt : how to make it work in the report

Started by mederik, 27 Apr 2012 08:26:48 AM

Previous topic - Next topic

mederik

Hi everyone,

I have a big problem to solve and I'll try to explain it simply.

  • I have a tree prompt named PERIOD and it parameter ?PERIOD? based on an essbase period axis
  • this tree prompt PERIOD, according to a test made in a variable based on oracle tables must have two differents default values
  • the test is something like : [ORACLE_TABLE].[Current_Day]<[ORACLE_TABLE].[Reference_Day] in a cognos boolean variable
    • I created a conditionnal bloc which tests that variable
    • in each bloc I pasted a different PERIOD tree prompt with its specific default value according to the test
      • It means I had to double this PERIOD tree prompts now named PERIOD_YES and PERIOD_NO. Each prompt, unfortunately, with a different parameter name otherwise it oesn't work : ?PERIOD_A? is associated with the tree prompt PERIOD_YES and ?PERIOD_B? with the tree prompt PERIOD_NO. Whereas before, I had only one : ?PERIOD?
      • now the problem of course is that i'm using in my main queries and filters objects that were calling the former value of that unique prompt period : ?PERIOD?
      • so in order the whole thing works I had to double everything (pages, queries etc...) so that, where needed, the objects use either ?PERIOD_A? or ?PERIOD_B?

      That method is working but it is very hard to maintain especially when reports are quite complictaed as those are.

      So have you had experienced the same issues and how did you solve it :
      to resume my issue : you had an existing tree prompt with one default value and now your business is asking you to developp a new version of the report where the same tree prompt must have two different default value according to a test that is conductiong in an oracle table.

      I thought that token may be a solution :
      #prompt('parameter','token',[MyEssbaseCube].[Period].[Period].[Periode : Total]->:[DO].[PER].[CN1M1P])#
      where "[MyEssbaseCube].[Period].[Period].[Periode : Total]->:[DO].[PER].[CN1M1P]" would be the default value corresponding to PERIOD_A but how to test that it must be PERIOD_A instead of PERIOD_B value.
      ???
      I'm confusing and lost, so please help ? :o :o

mederik

Hi,

After 4 days of headache and folding cognos upside down I finally found a very simple and elegant solution to that problem. It's a tiny javascript that goes all along the tree and select any member on the tree where specified. The only drawback is that it can only select level 1 members. Hopefully in my cas, my two default members to be choosen are level 1.

So for those who that may find it interesting here is how :


  • insert an HTML tag
  • into that tag paste the following code

<div id='my_tree'>


  • then insert the tree prompt
  • after the tree prompt insert a second HTML tag with the following code

</div>
<script>
var node = window.treeTime.getRootNode().getChildren()[window.treeTime.getRootNode().getChildren().length-2];
node.setSelected(true);
node.updateNodeSelection();
node.updateParent();
window.treeTime.setLastSelectedNode(node);
</script>


And that's it :D

So thanks a lot to Paul's Blog http://cognospaul.wordpress.com/ because it's there I found that great little script that saved my ass  8)