I have created a dashboard that has two WebResources. The first is a 3rd party customisation that accepts a data paramenter, the second is an HTML WebResource I have created.
What I want to do is update the parameter of the first WebResource with JavaScript, triggered when a user clicks a link in the WebResource I have created.
My understanding is that I should be able to achieve this using either of the following:
window.parent.Xrm.Page.getControl("TargetWebResourceName").setSrc("URL")
window.parent.Xrm.Page.ui.controls.get("TargetWebResourceName").setSrc("URL")
However this does not work.
For a reason I don't understand, when executed from the dashboard, the Xrm.Page.ui object is null, and results in the error: "Cannot read property 'controls' of null". This is not true of Xrm.Page.context - this works perfectly when trying to get things like user name.
As far as I can tell this is only an issue for the dashboard. In trying to diagnose the problem I created the following function - it works as expected in a WebResource on the Account Entity. It fails with the same error as above when run from the dashboard.
function DoesntWorkOnDashboard() {
var controlname = window.parent.Xrm.Page.getControl(1).getName();
alert(controlname);
}
I'm new at this and hopefully have missed something obvious. Is the dashboard different from other forms and the getControl method does not work? If so, is there another way I can achieve what I'm trying to do?
Thank you