Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Manipulate Inner HTML Web Resource

Posted on by 1,065

Hi, hope you all are doing great today.

Quick question… Is there a supported way to manipulate the inner HTML of a web resource?

Right now I have the following code to change the color and name of certaing HTML components, however, this is unsupported and I'm trying to find a workaround for MS Dynamics 365(UCI):

document.getElementById('segmentation_value').innerHTML = name;

var element = document.getElementsByClassName('div_container');
for (i = 0; i < element.length; i  ) {
    element[i].style.backgroundColor = bannerColor;
}

Thanks in advance!

  • Suggested answer
    Charles Abi Khirs Profile Picture
    Charles Abi Khirs 3,569 on at
    RE: Manipulate Inner HTML Web Resource

    Hello,

    You are on the safe side, because you are manipulating the DOM of your own html resource.

    The unsupported way is when you try to access and work with the DOM of the crm forms mainly fields and objects.

  • chikhaleankush Profile Picture
    chikhaleankush 547 on at
    RE: Manipulate Inner HTML Web Resource

    As mentioned in question, the components are inside your HTML created (custom) and method mentioned by you is correct.

    What is not supported, using DOM to manipulate CRM fields and objects. But in your case you are playing under your HTML, so you are fine and it is supported.

  • Suggested answer
    RE: Manipulate Inner HTML Web Resource

    Hello Enrique,

    Based on Microsoft documentation, the usage of DOM elements is not supported, please find the documentation below:

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/customizations-supported#common-unsupported-customization-practices

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/supported-customizations#customizations-applied-using-code

    What you can do instead in some situations is the following:

    Try to use an Web resource instead of the Dynamics form where you will use the Web API to get the data you want, or retrieve it directly from the form, but sending it over to the web resource will require some additional work, and define your own visualization from there, preferable without DOM elements, if possible.

    Based on the code you mentioned above you are updating the the color of the container elements and also you use getElementById and getElementByClassName which are not supported in the context of Dynamics.

    I hope this helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans