Microsoft Dynamics CRM

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

Advertisements

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

    1. 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?

    1. 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!

    1. 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

    1. 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. 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

  7. 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

  8. 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 ?

      1. I need to display the bpf field label text in colour to highlight it . in 2013 $(“#header_process_new_affiliate_c”).find(“span”).css(“color”, “red”); this one working fine . But i need same functionality in 2015 online …

  9. 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

  10. 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

  11. 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

      1. Hi Bijoy,

        This should work for you:

        $(‘#customemailfieldname’).find(‘a[class=”ms-crm-gridurl”]’).css(‘color’,’red’);

        Please note this is unsupported and might break in future releases.

        Hope it helps.

        Thanks and Regards,
        Deepesh

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s