Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Up Program - Building model-driven apps w...
Unanswered

How to Change Header Color Dynamically Based on Choice Column Value in Model-Driven App"

(0) ShareShare
ReportReport
Posted on by 103
"How can I dynamically change the header color in a Model-Driven App based on the selected value of a choice column? I have already created the choice column and need guidance on implementing this feature using JavaScript and Business Rules."?
 
function changeHeaderColor(executionContext) {
    var formContext = executionContext.getFormContext();
    var fieldValue = formContext.getAttribute("wd_statusoftriage").getText();
    // Define colors based on field value
    var colors = {
        "Critical Impact": "#FF0000", // Red
        "Serious Impact": "#FF6347", // Dark Red
        "Moderate Impact": "#FF7F7F", // Light Red
        "Minor Impact": "#90EE90", // Light Green
        "Routine Impact": "#00FF00"  // Bright Green
    };
    // Set header color based on field value
    var header = document.querySelector(".pa-headerview-bar");
    if (header && colors[fieldValue]) {
        header.style.backgroundColor = colors[fieldValue];
    }
}
 
Categories:

Under review

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

Leaderboard > Microsoft Power Up Program Community

#1
w.p Profile Picture

w.p 288

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 138 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 80 Super User 2025 Season 1

Featured topics