Skip to main content

Notifications

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 78
"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

#1
WarrenBelz Profile Picture

WarrenBelz 143,867

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,174

Leaderboard

Featured topics