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
Lisa Lee-BanksLisa Lee-Banks 

Syntax for image formula field

I've created a formula field with the syntax below to display a yellow box when the record status is 'Committed by client'. I would like to add the logic to check if the 'Closing Date' is within 14 days of today. Is this possible?

IF(ISPICKVAL( Status__c , 
"Committed by client"), IMAGE("/img/samples/color_yellow.gif ","yellow", 30,30),"Blank")
Best Answer chosen by Lisa Lee-Banks
VinayVinay (Salesforce Developers) 
Try below formula.
IF(Closing Date - TODAY() < 14,
IF(AND(ISPICKVAL( Status__c , 
"Cancelled")), IMAGE("/img/samples/color_yellow.gif ","yellow", 30,30),"Blank"),"Blank")

Please mark as Best Answer if above information was helpful.

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
Hi Lisa,

Do you want to add if the condition and execute above formula if the closing date is within 14 days?

Thanks,
Lisa Lee-BanksLisa Lee-Banks
Yes please. Thanks, *Lisa Lee-Banks* *Certified Salesforce Consultant* *604-908-9457* *Schedule a meeting *
VinayVinay (Salesforce Developers) 
Try below formula.
IF(Closing Date - TODAY() < 14,
IF(AND(ISPICKVAL( Status__c , 
"Cancelled")), IMAGE("/img/samples/color_yellow.gif ","yellow", 30,30),"Blank"),"Blank")

Please mark as Best Answer if above information was helpful.

Thanks,
This was selected as the best answer
Lisa Lee-BanksLisa Lee-Banks
Hi Vinay, I would like to add some more logic to this formula field. I have a checkbox that should also display the yellow box and the closing date and status don't matter. I tried adding OR before and after the existing logic but the syntax is wrong in both cases.
VinayVinay (Salesforce Developers) 
Try below.
IF(checkbox=true,
IF(Closing Date - TODAY() < 14,
IF(AND(ISPICKVAL( Status__c , 
"Cancelled")), IMAGE("/img/samples/color_yellow.gif ","yellow", 30,30),"Blank"),"Blank"),"Blank")
Thanks,
Lisa Lee-BanksLisa Lee-Banks
Thanks, Vinay. I tried this syntax but I think I need an OR condition because I always want the colour to display if the checkbox = TRUE OR the closing date is within 14 days and the status = Committed by client. *Lisa Lee-Banks* *Certified Salesforce Consultant* *604-908-9457* *Schedule a meeting *
VinayVinay (Salesforce Developers) 
IF(New_Date__c - TODAY() < 14  || checbox__c=true,
IF(AND(ISPICKVAL( Status__c , 
"Cancelled")), IMAGE("/img/samples/color_yellow.gif ","yellow", 30,30),"Blank"),"Blank")
Thanks,
Lisa Lee-BanksLisa Lee-Banks
Sorry to bother you again. I don't think I'm doing a very good job of explaining the requirement so I'll try again.
If the checkbox = TRUE the colour should display 
OR
If the closing date is with 14 days and the status = Committed by client the colour should display
Lisa Lee-BanksLisa Lee-Banks
Is this close to the correct syntax?

IF(COF__c = TRUE, IMAGE("/img/samples/color_red.gif ","red", 15,120),"blank")
OR(
IF( MtgPlanner_CRM__Closing_Date__c - TODAY() < 14,
IF(AND(ISPICKVAL( MtgPlanner_CRM__Status__c ,"Committed by client")),IMAGE("/img/samples/color_red.gif ","red", 15,120),"blank"))
VinayVinay (Salesforce Developers) 
No,  I believe this will not work.  Did you try above formula shared?  Do you see any errors or not working as expected.

It would be good if you have add details and screenshot and add as another query/question so that we can check.

Thanks,
Lisa Lee-BanksLisa Lee-Banks
Yes I did. There was no syntax error but unfortunately I wasn't getting the expected results.
I found this syntax works:
IF( OR( Checkbox = TRUE, AND( Closing_Date__c - TODAY() < 14, ISPICKVAL( Status__c , "Committed by client") )) , IMAGE("/img/samples/color_red.gif ", "red",15,120) , "blank")