Defer query execution on dashboard launch
Hi,
Is it possible to defer the execution of a SQL query against the db when a dashboard is launched until some dashboard JS code executes or a promise resolves?
Use case: I created dashboards that will call the reportAPI.drill() function on a drill-down report (report1) automatically on launch if the top-level column only has one value in the db. However, I do not want a report (report2) filtered by the drill hierarchy of report1 via the dashboard link interactions until after the report'1s data is evaluated and it is determined whether to call the drill API function on it.
This setup will send 2 queries to the db for report2 (one for initial load, then one once report1's data is evaluated and the drill function is called), when I only need report2's query to fire after report1 is loaded and the data is evaluated.
Hi Dillon,
Thanks for reaching out with this.
I've been looking into the potential of being able to do this however it lands a little bit out of scope of our capabilities in support. Allow me o reach out to the global support team to see if we don't have a way to do this. It may be that we need to reach out to our consultants for some guidance in implementing something like this.
Once I have a clearer idea on what if this is possible with the API I will update you promptly!
Let me know if you have any questions in the meantime.
Best,
Jared
Hi Dillon,
Thanks for reaching out with this.
I've been looking into the potential of being able to do this however it lands a little bit out of scope of our capabilities in support. Allow me o reach out to the global support team to see if we don't have a way to do this. It may be that we need to reach out to our consultants for some guidance in implementing something like this.
Once I have a clearer idea on what if this is possible with the API I will update you promptly!
Let me know if you have any questions in the meantime.
Best,
Jared
Hi Dillon,
I wanted to let you know I am still working on getting some information around this.
With the context of this question however this may be a bit involved for a Support Engagement and may need to be a larger conversation our Integration Specialists within the Consulting team.
I'll let you know what I am able to find out from the team and update you promptly.
Best,
Jared
Hi Dillon,
I wanted to let you know I am still working on getting some information around this.
With the context of this question however this may be a bit involved for a Support Engagement and may need to be a larger conversation our Integration Specialists within the Consulting team.
I'll let you know what I am able to find out from the team and update you promptly.
Best,
Jared
Hi Dillon,
I've heard back from a member of our dev team regarding this.
This is sort of possible - but it does currently rely on removing the reports from the page temporarily. Which isn't really ideal. It also doesn't guarantee that the report you are waiting to execute won't actually execute.
That said, this is some sample code that removes one report from the page and then re-adds it after the other report has completed. It achieves the effect of Report One not running till Report Two has complete, but it may not be quite what they are after.
Code mode code
=========
let canvas = this.apis.canvas;
let reportOneUUID = '03ddc4b8-f442-4865-9198-36b2fc7abaf6';
let reportTwoUUID = '3a8b6934-cf42-4809-ba27-2ecfafaaf964';
let reportOne = canvas.select('03ddc4b8-f442-4865-9198-36b2fc7abaf6');
let reportTwo = canvas.select('3a8b6934-cf42-4809-ba27-2ecfafaaf964');
//Get the parentElement of reportOne so we can reattch reportOne to it when reportTwo completes
let parentElement = reportOne.parentElement;
reportOne.remove();
let reportCompleteFn = function() {
reportTwo.removeEventListener('reportComplete', reportCompleteFn);
parentElement.appendChild(reportOne);
reportOne.reportAPI.runReport();
}
reportTwo.addEventListener('reportComplete', reportCompleteFn);
Lt me know if this code mode information helps you here!
As mentioned by our devs, we may need to raise this as an enhancement to get this functionality correct.
Best,
Jared
Hi Dillon,
I've heard back from a member of our dev team regarding this.
This is sort of possible - but it does currently rely on removing the reports from the page temporarily. Which isn't really ideal. It also doesn't guarantee that the report you are waiting to execute won't actually execute.
That said, this is some sample code that removes one report from the page and then re-adds it after the other report has completed. It achieves the effect of Report One not running till Report Two has complete, but it may not be quite what they are after.
Code mode code
=========
let canvas = this.apis.canvas;
let reportOneUUID = '03ddc4b8-f442-4865-9198-36b2fc7abaf6';
let reportTwoUUID = '3a8b6934-cf42-4809-ba27-2ecfafaaf964';
let reportOne = canvas.select('03ddc4b8-f442-4865-9198-36b2fc7abaf6');
let reportTwo = canvas.select('3a8b6934-cf42-4809-ba27-2ecfafaaf964');
//Get the parentElement of reportOne so we can reattch reportOne to it when reportTwo completes
let parentElement = reportOne.parentElement;
reportOne.remove();
let reportCompleteFn = function() {
reportTwo.removeEventListener('reportComplete', reportCompleteFn);
parentElement.appendChild(reportOne);
reportOne.reportAPI.runReport();
}
reportTwo.addEventListener('reportComplete', reportCompleteFn);
Lt me know if this code mode information helps you here!
As mentioned by our devs, we may need to raise this as an enhancement to get this functionality correct.
Best,
Jared
Hi Jared,
Thanks for the response, but as you said it doesn't seem like this is a reliable method of achieving what I'm looking for. The use case I have is to have several reports on a dashboard that should only ever be executed when they are displayed to the user. Ex: I have 5 reports, and only one of these is ever displayed to the user at a time based on whatever option is selected in a custom drop-down menu. Only the report that is visible should execute, and I need to be able to fire this query on demand from JS code while simultaneously NOT executing the other 4 queries for the 4 reports not currently visible to the user when the drop-down menu option is updated.
Please raise this as an enhancement request. Thanks!
Hi Jared,
Thanks for the response, but as you said it doesn't seem like this is a reliable method of achieving what I'm looking for. The use case I have is to have several reports on a dashboard that should only ever be executed when they are displayed to the user. Ex: I have 5 reports, and only one of these is ever displayed to the user at a time based on whatever option is selected in a custom drop-down menu. Only the report that is visible should execute, and I need to be able to fire this query on demand from JS code while simultaneously NOT executing the other 4 queries for the 4 reports not currently visible to the user when the drop-down menu option is updated.
Please raise this as an enhancement request. Thanks!
Hi Dillon,
No worries on that,
I've gone ahead and raised this as an Enhancement and have also turned this ticket into an Idea post so that we can track the progress of the enhancement here.
Let me know if you have any questions regarding any of this. Once I have any updates on this I will be sure to provide those here promptly.
Best,
Jared
Hi Dillon,
No worries on that,
I've gone ahead and raised this as an Enhancement and have also turned this ticket into an Idea post so that we can track the progress of the enhancement here.
Let me know if you have any questions regarding any of this. Once I have any updates on this I will be sure to provide those here promptly.
Best,
Jared
Replies have been locked on this page!