[SalesForce] add a custom message at the top of a page based on some criteria

Our tech support team uses cases for interacting with customers. Based on some criteria on the parent account, we are looking for a way to show a message to our tech support team indicating that this account is special.

I could go down the route of adding new fields, formulas and workflows; My hesitation is that the data already exists so this would result in duplicate data simply to meet this requirement.

I'm comfortable with Apex as I've written a handful of triggers, but, I have never tried something like this before so I thought I would seek input from the community.

Best Answer

You don't need apex at all!

  1. Create a new visualforce page with a standard controller based on your object
  2. In this page create an apex:pageMessage
  3. Set render criteria basen on some field
  4. Add this page to the object layout

Visualforce page:

<apex:page standardController="Account"
           sidebar="false"
           showHeader="false"
           showChat="false">

<apex:pageMessage summary="This pageMessage for the supporter" 
                  severity="warning" 
                  strength="3"
                  rendered="{!Account.Name = 'Hello'}" />
</apex:page>

Now go to the page layout and put a new section to the page, set a height to the 50px (you can read here about how to insert a page to the layout):

enter image description here

Put this visualforce page to the section and save the layout:

enter image description here

Related Topic