Globally scoped dashboard JavaScript

Dillon Hoefener shared this question 20 days ago
In Progress

Hi,

I've just started working with the concept of creating dashboards with multiple subtabs. I use code mode pretty heavily, and I found that the JavaScript code is scoped to the current subtab and runs only on the subtab launch.

I'm looking for a recommendation on how one should go about creating globally scoped code (dashboard scope that applies to all sub tabs, executed each time a sub tab is launched). Is this currently possible?

If so, can you point me toward any documentation you may have on this? I've looked through the wiki on the apis but don't see any info on this specifically.

Comments (5)

photo
1

Hi Dillon,


Thanks for your question.


I remember in earlier days of version 9, Code Mode might have been scoped globally, however, there were some issues where Reports and styling would repeat themselves. This might be a deliberate limitation of the scope of Code Mode as a result of those issues.


What exactly are you attempting to replicate globally in Code Mode? If I get a bit better of an understanding of the context I can ask my colleagues and Developers if they have any further suggestions. Styling, for example can be managed globally in the /customcss folder.


Kind regards,

Simon

photo
1

Hi Dillon,


I hope you are doing well!


I just wanted to check in with you regarding this issue, where I was looking at getting a better understanding of what you are trying to achieve with global scope using Code Mode. I might be able to offer some alternatives once I get a better understanding.


Kind regards,

Simon

photo
1

Hi Dillon,


As I haven't heard from you, I'm going to mark this as closed for the moment.


Feel free to re-open it at a later date with further information if you still require assistance.


Kind regards,

Simon

photo
1

Hi Simon,

Sorry for the delayed response... I'll present a scenario with the hope that you can provide a recommendation on the best way to go about the achieving the goal as the circumstances/challenges that led to me choosing this design are complicated and probably unique to our environment.

Let's say I have a dashboard with multiple sub tabs and I want to include one report on all the sub tabs, and the report should behave the same way on all tabs. This report is presented on the dashboard as a custom JavaScript chart that requires event listeners to be added via code (i.e. click a value and call drill down function via API to produce drilldown effect).

My question here is, must I replicate the code that controls this chart on every subtab? This would be a poor design obviously, because if I need to make a change to the code I have to make that change in the code on every sub tab. It seems that if I want to include a report on multiple tabs it must be added separately and coded for each instance on every subtab. My hope is there is a better way to go about coding this and YF may be able to enlighten me on that.

Thanks

photo
1

Hi Dillon,


I understand your goal here, and I will have to double check with Developers if it's possible.


As I alluded to earlier, my understanding is that Dashboards were initially set up in this way, however, due to a scoping defect that caused every chart to render as the first Javasript chart, a subtab by subtab scope was introduced. I'll get back to you once I hear back from Developers, however, at this stage I believe that you might have to repeat your code!


Kind regards,

Simon