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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

document.getelementbyid and document.getelementbyid.parentNode.insertBefore is not supported in D365

(0) ShareShare
ReportReport
Posted on by 62

Hi All ,
document.getelementbyid and document.getelementbyid.parentNode.insertBefore is not supported in D365
But i need to convert the above code to D365 supported solution . Turn on the  legacy form rendering the existing code is working.
Please help me on this. Thanks in  Advance.

var new_newcomaccountactive;
new_newcomaccountactive = document.getElementById("new_newcomaccountactive");
if (new_newcomaccountactive == null) {
new_newcomaccountactive = parent.document.getElementById("new_newcomaccountactive");
}
//if (new_newcomaccountactive && new_newcomaccountactive.checked)
//var new_newcomaccountactive = Xrm.Page.getAttribute("new_newcomaccountactive");
 //debugger;
if (new_newcomaccountactive && Xrm.Page.getAttribute("new_newcomaccountactive").getValue() == true) {
var urlPermissions = GetCrmSetting("new.Com Website URL") + "/accountcenter/admin/Permissions.aspx?crmContactId=" + Xrm.Page.data.entity.getId();
var spannewComPermissionsLink = document.createElement('span');
spannewComPermissionsLink.style.marginLeft = '30px';
var hrefnewComPermissionsLink = document.createElement('a');
hrefnewComPermissionsLink.setAttribute("href", urlPermissions);
hrefnewComPermissionsLink.setAttribute("target", "PermissionWindowFromCrm");
hrefnewComPermissionsLink.style.color = '#0000ff';
hrefnewComPermissionsLink.style.textDecoration = 'underline';
var textnewComPermissionsLink = document.createTextNode("new.COM Permissions");
hrefnewComPermissionsLink.appendChild(textnewComPermissionsLink);
spannewComPermissionsLink.appendChild(hrefnewComPermissionsLink);
new_newcomaccountactive.parentNode.insertBefore(spannewComPermissionsLink, getNextElementSibling(new_newcomaccountactive));
           }

*This post is locked for comments

I have the same question (0)
  • Jegan Profile Picture
    on at

    Hi All ,

    document.getelementbyid and document.getelementbyid.parentNode.insertBefore is not supported in D365 

    But i need to convert the above code to D365 supported solution . Turn on the  legacy form rendering the existing code is working.

    Please help me on this. Thanks in  Advance.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide the whole code and explain what does it do?

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi,

    use

    window.parent.document.getelementbyid

  • Verified answer
    manojd Profile Picture
    1,397 on at

    Jegan,

    I hope you know that document.getlelementbyid is not support by Microsoft & if you use this then your CRM instance becomes un-supported by Microsoft.

    As suggested by Andrew, suggest you provide your code or requirement so community can suggest you the workaround  

    Hope it answer your query

  • Jegan Profile Picture
    on at

    i have to convert to D365

    var new_newcomaccountactive;

               new_newcomaccountactive = document.getElementById("new_newcomaccountactive");

               if (new_newcomaccountactive == null) {

                   new_newcomaccountactive = parent.document.getElementById("new_newcomaccountactive");

               }

               //if (new_newcomaccountactive && new_newcomaccountactive.checked)

               //var new_newcomaccountactive = Xrm.Page.getAttribute("new_newcomaccountactive");

               //debugger;

               if (new_newcomaccountactive && Xrm.Page.getAttribute("new_newcomaccountactive").getValue() == true) {

                   var urlPermissions = GetCrmSetting("new.Com Website URL") + "/accountcenter/admin/Permissions.aspx?crmContactId=" + Xrm.Page.data.entity.getId();

                   var spannewComPermissionsLink = document.createElement('span');

                   spannewComPermissionsLink.style.marginLeft = '30px';

                   var hrefnewComPermissionsLink = document.createElement('a');

                   hrefnewComPermissionsLink.setAttribute("href", urlPermissions);

                   hrefnewComPermissionsLink.setAttribute("target", "PermissionWindowFromCrm");

                   hrefnewComPermissionsLink.style.color = '#0000ff';

                   hrefnewComPermissionsLink.style.textDecoration = 'underline';

                   var textnewComPermissionsLink = document.createTextNode("new.COM Permissions");

                   hrefnewComPermissionsLink.appendChild(textnewComPermissionsLink);

                   spannewComPermissionsLink.appendChild(hrefnewComPermissionsLink);

                   new_newcomaccountactive.parentNode.insertBefore(spannewComPermissionsLink, getNextElementSibling(new_newcomaccountactive));

               }

  • Jegan Profile Picture
    on at

    Thanks !.

    I will provide my code below the screen.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Looks like you're doing DOM injections. There is no supported way to convert your code do D365. The only possible way that I see at the moment is to create html/js webresource that will do pretty the same task - generate URL of special kind. You can check following article that describes basics - butenko.pro/.../howto-htmljs-webresources

  • Preeti Sharma Profile Picture
    2,678 on at

    try replacing document.getElementById to window.parent.document.getElementById as this is supported BY D635.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans