CRM 2016 Gotcha: Fix that unsupported JavaScript!

Printer-friendly version

It’s never officially recommended to write unsupported JavaScript for CRM, but it is sometimes necessary to fulfill certain requirements. Previous versions of CRM allowed a developer to access the DOM elements for fields on a form simply by using “document.getElementById,” but you might find that you can no longer find your fields after you upgrade to CRM 2016 (provided you’re not using legacy form rendering). Turns out that the cheese was just moved over a node, so popping a “parent” on there will possibly address your issues.

Take the code below, for instance. This is a function we use to collapse or expand a form row depending on the visibility of the field it contains. After upgrading to CRM 2016, that “document.getElementById(ctrlName + '_d');” was returning a null, but all that was needed was the red line to get things working again.

function Row_SetVisibility(ctrlName, value) {

    if (Xrm.Page.ui.controls.get(ctrlName) != null) {




    var row = document.getElementById(ctrlName + '_d');

    if (row == null) row = parent.document.getElementById(ctrlName + '_d');


    if (row != null) {

        if (value == true) {

   = '';

        } else {

   = 'none';




Still, this may be an excellent time to review some of that unsupported legacy JavaScript you have lying around to see if it can be replaced with something more appropriate. You never know how long that legacy form rendering checkbox will be around or if this workaround will still be available after the next release!

About the Author:

TopLine Strategies delivers the complete integration and development of sales, marketing and customer service technologies that enable corporate clientele to improve revenue streams and strengthen customer interactions. Our project management and consulting is designed to achieve timely delivery, 100 percent user adoption of the technologies we implement and deliver measurable returns on investments for our clients.

Comments (2)

Daveigh replied on

This is what we need - an insight to make evnoyree think

Oleksandr replied on

Thank you, it helped:)

Related Blogs

TheReact Native Open Source roadmap was announced in Q4 2018 after they decided to invest more in the React Native open source community.

October is not just about pumpkins, fall foliage, and cooler temps anymore. October 2018 also means the exciting introduction of Microsoft Dynamics 365 for Customer Engagement.

Back in 2016, Microsoft introduced its intentions to refresh its CRM and ERP strategy with Dynamics 365. At the heart of its services was the Common Data Model (CDM).