function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TNiemanTNieman 

Display a banner on Case Layout

I have successfully created a small banner on the top of the Case layout with a simply VF page 
 
<apex:page StandardController="Case" showHeader="false" standardStylesheets="false" sidebar="false">
    <body style="background-color:lightblue;">
        <div align="center">
            <h2>HCM Parent Case - {!Case.CaseNumber}</h2>
        </div> 
    </body>  
</apex:page>
Sample rendered
User-added image


I would like to create a new page that changes the background color based on Severity__c field. See below
//for Severity__c = 'Severity 1'
      	<body style="background-color:red;">
    	    	<div align="center">
        	    	<h2><b>Severity 1 Case</b></h2>
       		</div> 
	</body> 

//for Severity__c = 'Severity 2'
      	<body style="background-color:yellow;">
    	    	<div align="center">
        	    	<h2><b>Severity 2 Case</b></h2>
       		</div> 
	</body> 

//for everything else display nothing
I'm not sure how to accomplish this.  If it is not possible to have the "everything else" be empty, I could add the 2 remaining values of Severity__c as different colors
 
Best Answer chosen by TNieman
Prateek Singh SengarPrateek Singh Sengar
Hi,
You can put stylesheet based on the severity of the case. I tried the same thing with status value in my dev org and below is the code for the same
 
<apex:page standardController="Case">
    <body style="{!if(case.status == 'New', 'background-color:lightblue;', 'background-color:red;')}">
        <h2>
            Case : {!case.CaseNumber}
        </h2>
    </body>
</apex:page>

Please note that you can nest the if statement as well if required. In your case replace Status with your severity__c and values to your severity values.
Hope this helps.

All Answers

Prateek Singh SengarPrateek Singh Sengar
Hi,
You can put stylesheet based on the severity of the case. I tried the same thing with status value in my dev org and below is the code for the same
 
<apex:page standardController="Case">
    <body style="{!if(case.status == 'New', 'background-color:lightblue;', 'background-color:red;')}">
        <h2>
            Case : {!case.CaseNumber}
        </h2>
    </body>
</apex:page>

Please note that you can nest the if statement as well if required. In your case replace Status with your severity__c and values to your severity values.
Hope this helps.
This was selected as the best answer
TNiemanTNieman
Thanks Prateek! That worked
TNiemanTNieman
Here is the final code used for the VF page
 
<apex:page StandardController="Case" showHeader="false" standardStylesheets="false" sidebar="false">
	<body style="{!if(case.Severity__c == 'Severity 1', 'background-color:red;', 
                   if(case.Severity__c == 'Severity 2', 'background-color:yellow;',
                   if(case.Severity__c == 'Severity 3', 'background-color:lightgreen;',
                      'background-color:white;')))}">
    	<div align="center">
        	<h2>{!case.Severity__c} Case</h2>
        </div> 
    </body>  

</apex:page>

 
TNiemanTNieman
Note that I added some line breaks to help readability
TNiemanTNieman
I have tried to modify this for some other types of cases and conditions
<apex:page StandardController="Case" showHeader="false" standardStylesheets="false" sidebar="false">
    <body style="{!if(case.Is_CR_Parent_Case__c && NOT(Contains(case.Change_Management_Indicator__c, 'Approved')), 'background-color:black;',
                   if(case.Is_CR_Parent_Case__c && Contains(case.Change_Management_Indicator__c, 'Approved'), 'background-color:lightblue;',
                   'background-color:white;'))}">
        <div align="center">
            <h2>CR Parent Case - {!Case.CaseNumber}</h2>
        </div> 
    </body>  
</apex:page>

I am getting an error stating "Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Case.Is_CR_Parent_Case__c".  

This worked with a custom field Severity__c in the previous vf page without having a query. Why doesn't this one work?  The Is_CR_Parent_Case__c is on the page layout, so it Change_Management_Indicator__c.

I know I'll need to have more code to change the color of the text to make it white when the background is black.  Just trying to get past the query issue first.