Search code examples
javascriptdynamics-crm-2011dynamics-crmdynamics-crm-2016

Change the colour of text field in dynamics crm 2016


I am looking to write a javascript to change the color of any text field in CRM Here is my javascript:

function ChangeBackgroundColor()
{
     var revenue = window.parent.Xrm.Page.getAttribute("revenue").getValue();
     if(revenue < 10000)
     {
          document.getElementById("websiteurl").style.backgroundColor = "Red";

     }
}

It is throwing me an error saying "Cannot read property 'style' of null at ChangeBackgroundColor "

Can i get this customization done ? If yes then how? If no then why ?

Thanks in advance.


Solution

  • It is possible in Dynamics CRM 2016 but you will need to modify the setting 'Use Legacy Form Rendering' to 'Yes'. Go to Settings - Administration - System Settings then on the tab 'General' there is the setting 'Use Legacy Form Rendering'

    enter image description here

    Then your code will work.

    I would like to remind you that this is indeed unsupported and that it can be that it does not work anymore in future updates.