web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to change the header color (Header which contains user pictures) in dynamics 365 header

(0) ShareShare
ReportReport
Posted on by 20

How to change the header color in dynamics 365 header,Themes is not available in dynamics CRM 2013

I have the same question (0)
  • Suggested answer
    Venkatesh Nadar Profile Picture
    on at

    Here is one example -

    Scenario

    I am changing the account form header based on the value customertypecode option set field.

    • If the option set value is 1 then change the form header to red.
    • If the option set value is 2 then change the form header to green.
    • Else keep the default colour.

    Solution

    The solution consists of 3 web resources

    • CSS web resource for red colour
    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);
    }
    • CSS web resource for green colour
    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);
    }
    • JavaScript web resource to attach the relevant CSS file to the form
    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.
    pastedimage1653558945459v1.png
    Save and publish the changes and test the solution.

    Results

    If the option set value is 1.
    pastedimage1653558945460v2.png
    If the option set value is 2.
    pastedimage1653558945460v3.png

    Supported or Non Supported

    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

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 36 Super User 2025 Season 2

#2
Shivani Padalia Profile Picture

Shivani Padalia 36

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans