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)

Automatically retrieve the name of the web resource control in forms

(0) ShareShare
ReportReport
Posted on by

Hello,

I am creating a control for my Dynamics CRM forms. This control is basically a simple HTML web resource with some JS. In the JS code, I would like to do the following:

parent.Xrm.Page.getControl(currentControlName);


As the currentControlName is something that may change depending on who adds it the form, I do not want to hardcode in my resource:

var currentControlName = "WebResource_[a control name]";

Is there a way to automatically determine in which control my JS is running?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi sbelzile, you will need to iterate through the controls on the form using Xrm.Page.ui.controls.forEach(delegate function(control, index))..

    msdn.microsoft.com/.../dn481592.aspx

    You can then check the control type and also if it has a particular webresource...

    msdn.microsoft.com/.../gg334266.aspx

  • sbelzile Profile Picture
    on at

    Yes, the obvious alternative... I will try that, thanks for your help.

  • Albi29 Profile Picture
    5 on at

    I found the solution here: stackoverflow.com/.../dynamics-crm-dynamically-getting-html-webresource-parent-control

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