Change color for text fields : Dynamics CRM 2013

Sometimes we get requirement to change the forecolor for some fields in Dynamics CRM 2013 in order to highlight them in different color. So we implemented following script:

You can add the scripts on-load or based on some condition.

For changing color during field is non-selected:

//Setting red color

$(‘#fieldname’).find(‘div[class=”ms-crm-Inline-Value”]’).css(‘color’,color);

Now Field looks like this:

image

In order to change color during field is typed:

//Setting color blue during typing of field

$(‘#fieldname_i’).css(‘color’, color);

UI will look like below now:

image

Note: This is unsupported script and may break in future if Microsoft changes something.

Hope it helps!


Check this out

Trying to Learn Dynamics CRM: Download!

Learn Dynamics CRM App on Google Play store

45 thoughts on “Change color for text fields : Dynamics CRM 2013

    • Hi Jonathan,

      To change read only field color, Please use following script:

      $(‘#fieldname’).find(‘div[class=”ms-crm-Inline-Value ms-crm-Inline-Locked”]’).css(‘color’,’red’);

      Regards,
      Deepesh

  1. hello, i’ve tried your code but none is working, i am writing the exact id, i get no error and the result is no color on fields. i know that Dom is not supported for crm 2013, is any solution supported?

    • Hi ,

      I have double checked, i know this solution is unsupported and there is know supported one. After checking, script is working fine for me. If you are using Chrome console option to check, please select contentifame0 or contentiframe1 before trying to run the script. I am sure it will work for one or the other.Can you paste your script and condition, so that i can check once again. Is your field locked, then the script needs to be different.

  2. Hi Deepesh,

    The followng script does not seem to work. Am i missing anything.
    $(‘test’).find(‘div[class=”ms-crm-Inline-Value”]‘).css(‘color’, ‘red’);

    Thanks!

  3. very neat post! I was wondering if you knew how to change the color of the background on a business process flow from the standard grey and yellow? thanks so much!

    • Hi Brittney,

      I tried that in past and its really unsupported to change the colours, in case of on-premise it is possible. It consists of lot of elements to be changed and when I had tried for a customer, was not successful. I will not suggest doing it at all.It is not possible in CRM online.

      Hope it helps!

      Regards,
      Deepesh

  4. Thank you for this post !!
    I need some détails because I’m starting on development on Dynamics CRM 2013.
    Does this script should be in a .js or .css file which should be added in the web ressources ?
    I’ve created some .js script in order to change the background color of field, is it the same way to color text fields ?
    Thank you in advance for your repply.
    David

  5. Thank you for your answer Deepeesh.
    So I’ve created this script :

    function textcolor()
    {
    $(‘primarycontactid_d’).find(‘div[class=”ms-crm-Inline-Value”]’).css(‘color’,’red’);
    }

    that I call on the onload of the form properties in CRN Online 2013, after having declared it as a web ressource.
    But when I open my form in the application, I have an error : “textcolor is undefined”.

    Is there something wrong ?

    Thank you in advance for your help.

    Regards,

    David

    • Hi David,

      This script will only work for Text fields. I believe you are tying to use it on a lookup field.

      And another thing, it just needs fieldname no_d or _c even when used with text fields:

      $(‘#name’).find(‘div[class=”ms-crm-Inline-Value”]’).css(‘color’,’red’);

      Hope it helps!

      Regards,
      Deepesh

  6. For precision, I’ve tried on other fields (telephone1, name …) and same result.
    Maybe a syntax problem.

    David

  7. Thank you for your answer but it doesn’t work.
    To be easy, for example, I would like to color the font of the telephone field value for an account in CRM Online and here is my script :

    function textcolor()
    {
    $(‘telephone1’).find(‘div[class=”ms-crm-Inline-Value”]’).css(‘color’, ’red’);
    }

    but I always have the message : “textcolor” is undefined.

    Thank you in advance for your help

    Regards,

    David

  8. OK, I’ve found this solution which works fine !!

    $(“#name_c”).find(“span”).css(“color”, “red”); (for the label)
    $(“#name”).find(“span”).css(“color”, “red”); (for the value)

    Thank you for your help !!!

    Regards,

    David

    • This is working for lookup field.but if i am clicking the field color is changing to old color.

      Thank you in advance for your help.

  9. Can you get the font colour to change when a certain critia has been meet, for example

    I have contract dates shown and would like this to change colour when the date has expired ?

    • On the form on load event , you will need to call a function within a javascript webresource which will ave a if condition for your date field and if expired, you can use this code to change color

  10. Deepesh

    Can you do this on CRM 2015 online? Here is the code I am using but no luck

    jQuery(‘#alluvus_transactionowned’).find(‘div[class=”ms-crm-Inline-Value ms-crm-Inline-Locked”]’).css(‘color’,’red’);

    I used jQuery namespace instead of $.

    Jwalin

  11. Hi Deepesh,

    How we can change the color of Two Option Sets(Yes/No) based on selected Value. For Example: if I have selected “Yes” so color should be Red and for “No” color should be Blue.

    Thanks,
    Faisal

  12. Very nice article – it works for a normal text field. Could you tell me how to use for an email text field.

    The following keeps the filed value as default blue

    $(‘#custom_emailaddress’).find(‘div[class=”ms-crm-Inline-Value”]’).css(‘color’, ‘red’);

    So, basically I want to the email link value to be red

Leave a comment