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
Jaime RayJaime Ray 

Is there a way to show a red, yellow, or green image on the account based off when we closed won last opportunity

A user said at his old job that they have a image on the account page based off when the last closed won opportunity was.For example if it has been more than a year since the customer had a closed won opportunity, there would be a red image on the account page.

I am new to using forumla fields. I was wondering if someone could help me out please.
Best Answer chosen by Jaime Ray
badibadi
try this 

IF( FLOOR( (TODAY() - ClosedwonOppsRollUpField__c )/365.2425) == 0,  IMAGE(" /resource/Green",'Good') , IMAGE(" /resource/Red",'bad'))
 

All Answers

lokeguptalokegupta
Hi,

Here is my quick answer 

1. Create a visualforce page , code is here 

<apex:page standardController="Opportunity" tabStyle="Opportunity"> 
    <apex:outputpanel rendered="{!Opportunity.StageName == 'Closed Won'}">
       <div style="background-color:#F00">Closed Won</div>
    </apex:outputpanel>
</apex:page>

I am using color code (css) but you can upload images in resources and based on your logic you can show and hide them.

2. Now go to Layout of Opportunity and embed this visualforce page anywhere in layout.

If you need more help please let me know.

Thanks
Lokesh
badibadi
You can do it from Formula fields, 
  • Images: Save it in Static Resources e.g: green, red and yellowdot. Make static resources as public
  • Get the latest closed won opportunity on Account - I would have a rollup summary field for max closed date with opportunity with stage "Closed won" or something
  • Display the image
           Create formula field of type text 
           IF( YEAR(TODAY()) - YEAR( ClosedwonOppsRollUpField__c ) == 0,  IMAGE(" /resource/Green",'Good') ,
                    IF(YEAR(TODAY()) - YEAR( ClosedwonOppsRollUpField__c ) == 1, IMAGE(" /resource/Yellow",'not bad') , IMAGE(" /resource/Red",'bad')) )


 
Jaime RayJaime Ray
Hello Lokesh,
I have tried what you suggested. I would like a red line to show on the account page if there has not been a closed won opportunity in the last year.


 
Jaime RayJaime Ray
Hello Badi,
that worked. 

what if I want it to show up 1 year to be red.

 
Jaime RayJaime Ray
I thought something like this would work.
try to just use eonly red or green. but I am getting an error message saying Error: Syntax error. Extra ','

IF( YEAR(TODAY)) - YEAR( ClosedwonOppsRollUpField__c ) == 0,  IMAGE(" /resource/Green",'Good') ,
                    IF(YEAR(TODAY)) - YEAR( ClosedwonOppsRollUpField__c ) == 1, IMAGE(" /resource/Red",'bad'))

 
badibadi
try this 

IF( FLOOR( (TODAY() - ClosedwonOppsRollUpField__c )/365.2425) == 0,  IMAGE(" /resource/Green",'Good') , IMAGE(" /resource/Red",'bad'))
 
This was selected as the best answer