Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

How can I execute JavaScript functions automatically across all dashboards?

Received Response
51
Views
4
Comments
malcolmcarey
malcolmcarey Rank 2 - Community Beginner

I've tried to search around on this topic quite a bit and haven't found exactly what I'm looking for yet, but sorry if this question already exists somewhere.

Current Situation:

We have several dashboards and would like to apply some custom styling to each page using JavaScript. I've written a couple lines and then added it to a text element on a dashboard with HTML markup, and it is working fine. Now, in an effort to avoid adding this script and text element to every single dashboard (and every future dashboard), I tried researching ways to add this function in one place and have it execute across all dashboards on page load. I ended up tacking on this function to the end of the common.js file:

window.onload = function(){...};

However, after loading the page, the JavaScript either is not executing or it just didn't work. Every time I've seen someone add functions to the common.js file, it is as a function definition and then the function is called with a text element later in the dashboard.

So my question is am I able to add a JavaScript function to common.js (or another server JavaScript file) and have it automatically run when each dashboard loads?

Thanks for the help

EDIT: We are using OBIEE 12c.

Answers

  • What version is your OBIEE?

  • malcolmcarey
    malcolmcarey Rank 2 - Community Beginner

    Sorry, we're using OBIEE 12c. I've updated the post

  • 12c comes with jQuery loaded and heavily used out of the box.

    window.onload is a really really old way to try to make things, have a look at https://api.jquery.com/ready/ and use the jQuery event handler, it will always work (as long as the page is fine).

    It also depends on what your code try to change, because if you try to modify something that isn't already in the page it can't work (like if you try to change pieces of analysis, but analysis are loaded in an asynchronous way, so they come after the page and require different kind of JS to have an event handler matching it.

  • malcolmcarey
    malcolmcarey Rank 2 - Community Beginner

    Well jQuery or JavaScript, I still don't see how I can make a change in one place and have it apply to all dashboards. Just to provide some background, I am very new to OBIEE and JavaScript and have been struggling to find some helpful info on this.