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)

JavaScript error after upgrade to CRM 2016

(0) ShareShare
ReportReport
Posted on by

I'm tracking down and trying to fix a number of javascript errors that have appeared after we performed a move to CRM 2016. JavaScript I'm comfortable with, but I do not know anything about CRM.  Some of the errors were simple to fix and all I had to do was change "document.getElement..." to "parent.document.getElement...".

However, there are a number of errors that are of the type 'Cannot read property '_behaviors' (shown below) that are being stubborn and I'd appreciate any help in finding their solution. Thanks.

---------------------------------- Code ----------------------------

parent.document.getElementById("old_something_i")._behaviors[0].AddParam("disable", "1");

--------------------------------------------------------------------

---------------------------------Error-----------------------------------------

TypeError: Cannot read property '_behaviors' of null
    at NameOfJavascriptMethodAppearsHere (xxxxx/.../new_thisIsTheNameofMyScript)
    at eval (eval at RunHandlerInternal (xxxxxxx/.../ClientApiWrapper.aspx), <anonymous>:1:1)
    at RunHandlerInternal (xxxxxxx/.../ClientApiWrapper.aspx)
    at RunHandlers (xxxxxxx/.../ClientApiWrapper.aspx)
    at OnScriptTagLoaded (xxxxxxxx/.../ClientApiWrapper.aspx)
    at http://xxxxxxx/xxxxxx/form/ClientApiWrapper.aspx?ver=1106676978:201:1

------------------------------------------------------------------------------------------------------

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    The fundamental issue is that the code is trying to access DHTML elements that probably no longer exist in CRM 2016. It has always been unsupported to access the DHTML elements because they may not stay the same across upgrades.

    The ideal resolution would be to replace the code with supported functionality. The code you posted looks like it is to disable a field, which can be done in a supported way either through business rules (no code required), or the setDisabled method in java script

  • Verified answer
    Clem Profile Picture
    2,541 on at

    Agreed with David.

    You can't use function like : "document.getElementById("old_something_i")" to retrieve / set values.

    You have to use Xrm.Page.ui.controls.get("old_something_i").setDisabled(true); if you want to disable something (i think according to your code)

    Clément

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

    @David I believe topicstarted uses approach similar to one that David Berry posted - crmentropy.blogspot.com/.../add-parameters-to-crm-2011-lookup-dialog.html - looks like it disables lookup field inside lookup dialog.

    @jsChicago - I'm fan of supported customizations but sometimes it's really hard to implement something in supported way comaping to unsupported hack. I would suggest you to try to enable "legacy form rendering" - www.powerobjects.com/.../new-form-rendering-engine-in-dynamics-crm-2015

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