
How to change the header color in dynamics 365 header,Themes is not available in dynamics CRM 2013
Here is one example -
I am changing the account form header based on the value customertypecode option set field.
The solution consists of 3 web resources
I have named this web resource “new_/ColoredHeaderRed.css”. Here is the code.
.ms-crm-Form-HeaderContainer{
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#FF0000, endColorstr=#fff6f8faE);
}
I have named this web resource “new_/ColoredHeaderGreen.css”. Here is the code.
.ms-crm-Form-HeaderContainer{
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#008000, endColorstr=#fff6f8faE);
}
I have named this web resource “new_/ColoredHeaderScript.js”. The code is using a switch statement to attach an appropriate CSS file to the form, based on the value of customertypecode option set field. I am not using default in my switch statement as I don’t want to create a CSS file for default colour. Here is a code.
function loadCSS()
{
// get the value picklist field
var relType = Xrm.Page.getAttribute("customertypecode").getValue();
var filename;
switch (relType) {
case 1:
filename="/WebResources/new_/ColoredHeaderRed.css";
attachCSS(filename);
break;
case 2:
filename="/WebResources/new_/ColoredHeaderGreen.css";
attachCSS(filename);
break;
}
}// end function
function attachCSS(filename){
var fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", filename);
document.getElementsByTagName("head")[0].appendChild(fileref);
}
Now call the loadCSS() function on account form load event.
Save and publish the changes and test the solution.
If the option set value is 1.
If the option set value is 2.
CSS web resources are not meant to be used to change the style of the built in forms. So technically it is unsupported. But, we are not trying to retrieve the value of field or DOM object. We are just attaching a style sheet. If the Microsoft decided to change the name of the header class, it may stop the code to change the header colour but it won’t break the system.
Hope this Helps!
Regards,
Venkatesh N