web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to select a Dashboard WebResource with JavaScript?

(0) ShareShare
ReportReport
Posted on by 570

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

*This post is locked for comments

I have the same question (0)
  • Luis Bastos Profile Picture
    5 on at

    Hello Dan, 

    Did you find out a solution for this? I'm having the same problem atm and trying to figure out a possible solution

    Thanks

  • Community Member Profile Picture
    on at

    Dan,

    Could you please share the outcome of the issue if you have resolved.

    Harihar

  • Dan Field Profile Picture
    570 on at

    Apologies. I didn't find an answer to this question. I ended up working around it by creating multiple dashboards and reloading the dashboard frame when a user clicked a link. Not a solution I was very happy with but it got me more or less where I needed to go.

  • Community Member Profile Picture
    on at

    Thanks Dan.

    Harihar

  • BennB Profile Picture
    on at

    This is a little late and I only came across this now. Would the following help you out?

    var resource = document.getElementById("TargetWebResourceName");
    resource.src = value;
    OR

    // if you are trying to set a parameter of the url of the resource
    resource
    .control.SetParameter("URL", value);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans