Saturday, March 15, 2014

How to change Salesforce text colour?

As you all aware, Salesforce text in web user interface (UI) is only with black and dark grey colour, that's all and you not able to configure it.
But, is it possible if I need to have a red colour for some text or text with some conditions in the page layout so my user can notice something quickly?

Yes, but it is not easy, meaning you need to do something. Visualforce and with apex code if necessary.

Here a sample visualforce page using standard Account controller for account page layout:

<apex:page standardController="Account">
<apex:outputText value="The unformatted time right now is: {!NOW()}" />
<font color="red">
<apex:outputText value="The formatted time IN GMT IS : 
{0,date,yyyy.MM.dd G 'at' HH:mm:ss z}">
<apex:param value="{!NOW()}" />

As you can see, we just use standard HTML <font> color attribute, this mean you can use other standard HTML tags in visualforce as needed.

Add this visualforce page into Account page layout and you are done.

This is the result, see text in red:

Make sure your visualforce is using standardController rather than Controller, if you need logic with apex class, add extensions in vf page, example: <apex:page standardController="Account" extensions="MyController">
Otherwise, you will not able to add the visualforce page into standard page layout.

Reference: How to embed Visual Force page in a page layout?

No comments:

Post a Comment

Page-level ad