shows the message(Close date is near) on opportunity when a particular opportunity's close date is 5 days ahead
2 Answers
In addition to the Lightning Experience suggestion from @Raspi, for Salesforce Classic, you can simply create an image formula field that looks like this:
IF (TODAY() + 5 = CloseDate,
IMAGE("/img/samples/flag_yellow.gif" , 'Yellow' ,12,12) & ' Close Date is imminent. Do something!' & BR(),
NULL)
and place the formula field on the page layout, perhaps in an untitled section at the top. I use this technique to display 'soft alerts' that appear only when viewing a record. You can have many image expressions within one formula field.
Do you need it in the current Record Page as 'advise' ?
I usually use a Lightning component with some rules, using TOAST advises. An invisible Lightning component that handler the INIT and if some rules are true, then i call 'showToast' function:
showToast : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Close Date is near!",
"message": "The Close date is 5 days ahead!",
"type": "warning",
"mode": "pester"
});
toastEvent.fire();}
See documentation here: Lightning Component Show Toast
IMPORTANT! : Just for Lightning Experience Layout. If do you need for Salesforce Classic, you must build a Visualforce Page with an 'alert()'.