Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : 3Xrw18JWR0cJsB4OOtxcVx
Microsoft Dynamics CRM (Archived)

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

Like (0) ShareShare
ReportReport
Posted on 8 Dec 2017 13:23:30 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

  • Preeti Sharma Profile Picture
    2,678 on 09 Dec 2017 at 04:28:12
    RE: document.getelementbyid and document.getelementbyid.parentNode.insertBefore is not supported in D365

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

  • Suggested answer
    a33ik Profile Picture
    84,325 Most Valuable Professional on 08 Dec 2017 at 13:31:50
    RE: document.getelementbyid and document.getelementbyid.parentNode.insertBeforeis not supported in D365

    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

  • Jegan Profile Picture
    on 08 Dec 2017 at 12:24:37
    RE: document.getelementbyid and document.getelementbyid.parentNode.insertBeforeis not supported in D365

    Thanks !.

    I will provide my code below the screen.

  • Jegan Profile Picture
    on 08 Dec 2017 at 12:22:26
    RE: document.getelementbyid and document.getelementbyid.parentNode.insertBeforeis not supported in D365

    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));

               }

  • Verified answer
    manojd  Profile Picture
    1,397 on 08 Dec 2017 at 11:10:36
    RE: document.getelementbyid and document.getelementbyid.parentNode.insertBeforeis not supported in D365

    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

  • Suggested answer
    Iswarya Profile Picture
    1,345 on 08 Dec 2017 at 11:08:02
    RE: document.getelementbyid and document.getelementbyid.parentNode.insertBeforeis not supported in D365

    Hi,

    use

    window.parent.document.getelementbyid

  • a33ik Profile Picture
    84,325 Most Valuable Professional on 08 Dec 2017 at 11:03:14
    RE: document.getelementbyid and document.getelementbyid.parentNode.insertBeforeis not supported in D365

    Hello,

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

  • Jegan Profile Picture
    on 08 Dec 2017 at 11:03:13
    document.getelementbyid and document.getelementbyid.parentNode.insertBeforeis not supported in D365

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,878 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,748 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete