Auto-Expand Tree Prompt in Cognos 10.2.1.5

Here’s a javascript solution that will automatically expand tree prompts in Cognos 10.2.1.5

Expanded

There are two HTML tags required for this to work. Before the tree prompt, you need:

<span id="TreeName"></code>

and after the tree prompt, you need:

<code></span>

<script type="text/javascript">

	setTimeout (function() {document.getElementById('TreeName').getElementsByTagName('img')[0].click()}, 1000);

</script>

The script works by:

  1. Waiting 1000 milliseconds for the prompt to be loaded
  2. Finding the span that contains the ‘TreeName’ tree prompt
  3. Finding the first img element within that span. Note: For this solution to work, you must hide adornments
  4. Sending a click action to that element.

The full XML of this solution against GO Sales is available here.

8 Comments

  1. Marius says:

    Hi Andrew,

    Great tip and example you got here, thank you very much. I am testing it on Cognos 10.2.2 and it seems to be working fine but only expands one level down. Is it possible to have it expand multiple levels?

    For instance in product dimension of GO Sales could you have it expand from Product line and all the way down to Product:
    Product line
    Product type
    Product

    Regards,
    Marius

  2. Andrew Mosey says:

    Hello Marius, and thanks for making the first comment on this blog 😀

    I think there would be challenges using this technique to expand a second level via javascript – certainly we’d need to build a few delays into the script as Cognos will only expand one checkbox at a time. Also the delays seem to be cumulative, it’d require quite a bit of tinkering to get it working I imagine.

    Hope this helps,
    Andrew.

  3. Tanu says:

    Hi Andrew

    I think I have the same scenario. I need auto expanded Tree prompt and my tree prompt has a total of 7 levels, and by default I want it to expand till Level 4. How can I achieve this ?

    Thank you.

    Regards,
    Tanu

    • Andrew Mosey says:

      Hi Tanu,
      I’ve not found a way to expand these tree prompts out further than the first level in a robust manner. We also have a 8 level hierarchy and it can be a real issue for adoption of the solution.

  4. Dawna says:

    I love this solution. Thanks for sharing. Question…how do I expand this to do multiple tree prompts? Just giving the second tree prompt a new id name is not enough. Thank you.

  5. Andrew Mosey says:

    Hi Dawna,

    This should work for multiple tree prompts, just be sure to have the opening and closing script around each tree, and update the ids to match in each case.

  6. Prasad Loke says:

    Hello andrew, will this work in cognos analytics 11.0.6 as well?

    I am trying but it doesn’t seem to work, do I need to make changes in this?

    • Andrew Mosey says:

      Hi Prasad,

      Probably, however I no longer have access to a Cognos environment to test it. Good luck.

Leave a Comment