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)

Dynamics CRM 2015 Update 1 ....JavaScript Error Runtime Error

(0) ShareShare
ReportReport
Posted on by

Hello,

I have a JavaScript runtime error after updating to Dynamics CRM 2015 Update 1.

My custom JavaScript  is validated and passed the validation done through CRM 2015 Custom Validation Tool. As specified below, when the JavaScript run on page load, it grabs the single line text control and changes it to a hyperlink.

Here the code: 

// JavaScript source code

function

ConvertTfsItemFieldToLink() {

   //Get  URL

var itemInputId = Xrm.Page.data.entity.attributes.get("control_name").getValue()

var baseUrl = "";

var url = baseUrl + itemInputId;

var ctrl = Xrm.Page.ui.controls.get("control_name");

//Get contol fist HTM element

var elem = ctrl.get_chromeElement()[0]

if (itemInputId != null) {

          Xrm.Page.data.entity.attributes.get("Control_Name").setValue(itemInputId);

       var btn = "<a href='javascript: void(0);' onclick=\"window.open('" + url + "'); return false; \" style='color:blue;text-decoration:underline !important'>" + itemInputId + "</a>";

  // Add the new button

    elem.innerHTML = btn;

    }

   else {

        Xrm.Page.data.entity.attributes.get("Control_Name").setValue(null);

        elem.innerHTML ='<span/>';

    }

}

The script throws the following error:

TypeError: Object doesn't support property or method 'get_chromeElement'
   at ConvertTfsItemFieldToLink (https://virtcrmsandbox2014.crm.dynamics.com/%7B635732137750002040%7D/WebResources/new_TFS_WorkItem_Case_Integration?ver=977649996:12:5)
   at eval code (eval code:1:1)
   at RunHandlerInternal (https://virtcrmsandbox2014.crm.dynamics.com/form/ClientApiWrapper.aspx:142:1)
   at RunHandlers (https://virtcrmsandbox2014.crm.dynamics.com/form/ClientApiWrapper.aspx:101:1)
   at ExecuteHandler (https://virtcrmsandbox2014.crm.dynamics.com/form/ClientApiWrapper.aspx:78:1)
   at $Av_1 (https://virtcrmsandbox2014.crm.dynamics.com/_static/form/formcontrols.js?ver=977649996:2935:17)
   at executeHandler (https://virtcrmsandbox2014.crm.dynamics.com/_static/form/formcontrols.js?ver=977649996:2881:13)
   at executeHandlerByDescriptor (https://virtcrmsandbox2014.crm.dynamics.com/_static/form/formcontrols.js?ver=977649996:2912:13)
   at Anonymous function (https://virtcrmsandbox2014.crm.dynamics.com/_static/form/formcontrols.js?ver=977649996:2920:13)
   at Anonymous function (https://virtcrmsandbox2014.crm.dynamics.com/_common/global.ashx?ver=977649996:22662:109474)

I know that get_chromeElement may be removed from Control API.

Is there anyway I can resolve that.

Thanks.

Yoyo

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,564 on at

    With the latest update and the new form rendering engine you aren't able to attach to the specific DOM elements any longer.

    http://blogs.msdn.com/b/crm/archive/2015/04/29/microsoft-dynamics-crm-online-2015-update-1-new-form-rendering-engine.aspx

    The short term way to overcome this is to turn back on the legacy engine in the Settings area (Navigate to Settings -> Administration -> System Settings -> General). The long term solution would be to use a web resource instead. 

  • Community Member Profile Picture
    on at

    Thank you Jason,

    I got the issue related to attaching to specific DOM object.

    I want to add a link in a form based on a value in another single line text field.

    What do you suggest? Or do you have any web resource approach to do this?

    Thanks

  • Verified answer
    MilindP Profile Picture
    1,019 on at

    this is how you can show it in web resource.... i am using "name" attribute from the form in to web resource

    keep the  web resource formatting... 2 rows with no scrolling

    you may adjust the HTML properties according to your need

    <html>

    <head>

       <meta charset="utf-8">

       <title>Operations Panel</title>

       ï»¿<style type="text/css">

           body {

               font-family: Segoe UI, Tahoma, Arial;

               background-color: #d6e8ff;

               margin:0;

               padding:0;

               vertical-align: top;

           }

           tbody {

               background-color: white;

           }

           th {

               background-color: black;

               color: White;

           }

           p {

               margin-top: 0;

               margin-bottom: 0;

               margin-left: 0;

               margin-right: 0;

           }

       </style>

       <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>

       <script type="text/javascript">

           document.onreadystatechange = function () {

               if (document.readyState == "complete") {

                   var message = document.createElement("DIV");

                   message.innerHTML = "<a href='https://www.msn.com/&#39; target='_blank'>" + window.parent.Xrm.Page.getAttribute("name").getValue() + "</a>";

                   //setText(message, Description);

                   document.body.appendChild(message);

                   //alert(window.parent.Xrm.Page.getAttribute("name").getValue());

               }

           }

       </script>

    </head>

    <body leftmargin=0 topmargin=0>

    </body>

    </html>

  • Community Member Profile Picture
    on at

    Thank you MillindP. It is a great solution. It worked for me.

    This can sbe marked as answered

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans