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:
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:
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
can you change a read-only field color?
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
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.
Hello Deepesh, are you aware of any supported solution to color fields?
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!
I do not thin there can be attribute name like test you need to be using logical name instead of test. Hope it helps!
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
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
Hi David,
You need to put this in .js webresource and call a function from it onload event of form.
Please note this is unsupported scripting.
Hope it helps!
Regards,
Deepesh
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
For precision, I’ve tried on other fields (telephone1, name …) and same result.
Maybe a syntax problem.
David
If you anyhow want to use it with lookup: $(‘#parentaccountid’).find(‘span[class=”ms-crm-Lookup-Item-Read”]’).css(‘color’,’red’);
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
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.
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 ?
Yes just on load do a validation before the script shared by me on the date.
If the date is crossed, you can change the colour.
Hope it helps!
Thank you for that, sorry but where would I put this code when creating the new field ?
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
Great thank you very much for you help !
You are welcome . Great to now it helped you.
I need this functionality on 2015 online version..please help
Hi Prasanna. What is the issue you are facing?
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 …
Hi Prasanna, Different class might apply for Business Process flow. However, I will highlight the fact that this is unsupported approach.
Why this not work in new CRM 2015 Online?
Hi Jakub,
As this is unsupported change, this can break with rollups or updates as the underlying classes might have changes.
Regards,
Deepesh
Hi Deepesh,
and exist now solution to solve this? Change color on text field?
Thx
Jakub
I do not think there is supported solution to solve this for text. Themes in CRM 2015 update 1 are a start in that direction but are limited to links at the moment.
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
Hi this is unsupported script and needs to be changed for each version this is better : https://dynamicsofdynamicscrm.wordpress.com/2015/05/27/supported-and-upgradeable-approach-to-colour-some-relevant-crm-form-fields-for-dynamics-crm/
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
Please check this : https://dynamicsofdynamicscrm.wordpress.com/2015/05/27/supported-and-upgradeable-approach-to-colour-some-relevant-crm-form-fields-for-dynamics-crm/
[…] 2) unsupported script – Change color for text fields […]
[…] Change color for text fields : Dynamics CRM 2013 […]
yeh link check karo Deepesh http://saikrishnayadav.blogspot.in/2015/03/change-color-for-text-fields-dynamics.html
nice copy 🙂
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
Hi Bijoy,
What version of CRM are you using?
Thanks and Regards,
Deepesh
I am using CRM 2013 On-Premise
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
[…] https://dynamicsofdynamicscrm.com/2014/05/06/change-color-for-text-fields-dynamics-crm-2013/ […]