Script changes when embedding dashboard into another dash

Hey everyone, I have a dashboard that works well on its own. One button on it directly manipulates a parameter, as such:

var view = this.parentView.control;

var impsParam = view.getViewParameterByName("impsParam");
impsParam.parameterValue.clearTokens();
impsParam.parameterValue.clearValues();
impsParam.parameterValue.lowerBoundaryValue = 0;
impsParam.parameterValue.upperBoundaryValue = 0;
impsParam.invalidateParameterValueLastModifiedTime();
impsParam.refreshAllAdapters();

However, I’m now embedding this dash into a template cell of another master dashboard. Now, this button doesn’t work.

I’m guessing I need to alter the view in some way, right? Because now the parentView is no longer the correct handle?

ADDENDUM: when looking in console, clicking these buttons throws no errors. I even went in and verified that the parameter value successfully changes. However, the filter does not respond. And again, it DOES work when I do it on the standalone (non-embedded) version of the dash.

Hello,

The method refreshAllAdapters has other parameters that must be specified if you’re embedding it. Specifically in this case you must give it the view to refresh on.

In this situation I think you can change your call to the following:

impsParam.refreshAllAdapters(false, this.parentView);

Which should allow it to refresh within the context of the child embedded dashboard.

2 Likes

You. Are. My. Hero.

Not only was this timely, but it works in BOTH the standalone and embedded versions of the dash.

Thank you so much. You saved the day!

2 Likes

Hi Ken. You’re right, and from what I saw it looks like we suggested calling the method this way in some of our articles, but our examples commonly just called the method without any arguments. This usually works, but it would be good to always pass the current view to this method in case it’s ever contained inside of another view later and I’ve passed this thread on so that our examples are updated to hopefully prevent this kind of problem in the future. Thanks for raising it!

1 Like