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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

innerHtml sends an error since version 9

(0) ShareShare
ReportReport
Posted on by

Hi,

I was using document.getElementById("myid").innerHTML = "some html code"

After the migration to version 9, this is not working anymore and throw the error

TypeError: Cannot set property 'innerHTML' of null

As the goal is to set HTML, what is the workaround?

Regards,

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: innerHtml sends an error since version 9

    First of all this is unsupported code in CRM as it’s directly doing DOM manipulation.

    Verify if the passing “myid” or any other actual schema name is valid.

    Check if the control with name is present or not before accessing its properties. For ex:

    if(document.getElementById("myid") != null)
        document.getElementById("myid").innerHTML = "some html code";
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: innerHtml sends an error since version 9

    Is it inside custom HTML? or you are referencing  CRM OOB field?

    If you are using custom HTML , it might be the reason that  your script runs before all DOM has been loaded, when you trying to get element which isn't parsed yet that's why you get error. If you are using custom HTML place your script tags after body closing tag thats ensures that whole document has been already parsed when the script starts executing.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: innerHtml sends an error since version 9

    Hi,

    This is one of the reason why you shoundn't be using the unsupported code. During the upgrade Microsoft can change the id of the elements and which is it seems happened here. Try to find the supported way of doing what you are currently doing. If there is no supported way and you still want to do use the current code then verify if the id is still same for the element post upgrade?

    Hope this helps.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: innerHtml sends an error since version 9

    The history is that in the previous version the element was not hidden in the DOM, so I can hide it with HTML. In the version 9, the element was really hidden in the DOM and was not accessible anymore in HTML and of course, the error was thrown. Thank you for your help.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans