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
geis6geis6 

Formula for image field...Help Please!

Hi,

I'm trying to create an image field that would populate the red flag image (/img/samples/flag_red.gif) when the boolean operator "HasCommentsUnreadBy Owner" is set to true.  It can either have a no flag, or the green flag (/img/samples/flag_green.gif) when the operator is set to false.

I've tried a variety of "IF" formulas with no sucess actually displaying the image.  I can get text to show up based on the formula's conditions.

Here are just some of the formulas I've tried:

IF(HasCommentsUnreadByOwner, "/img/samples/flag_red.gif", "/s.gif") - Doesn't wortk

IF(HasCommentsUnreadByOwner=True, "YES", "NO") - Works but this is not the image I prefer

IMAGE(
"/servlet/servlet.FileDownload?file=" &
IF(
HasCommentsUnreadByOwner=True,
"015R00000000iqS",
IF(
HasCommentsUnreadByOwner=False,
"015R00000000iqT"
)    -----Syntax is wrong on this one, I thried adding the pictures to the docs tab.


Can somone lend assistance?  Also, anyone have some good sources on formulas and sytax and learning them?

Cheers,
Ward


justajaynejustajayne
https://na3.salesforce.com/help/doc/en/salesforce_useful_formula_fields.pdf
 
 
Try image links ( on page 15) if you haven't already done so.
 
Hope this helps :)
geis6geis6
Thanks justajayne,

I tried this formula:

IF( Case_Age__c > 20,
IMAGE("/img/samples/color_red.gif", "red", 30, 30),
IF( Case_Age__c > 10,
IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30),
IMAGE("/img/samples/color_green.gif", "green", 30, 30),
) )

Apparently, the syntax isn't even correct in te documentation, I get this error just pasting it into my field.  "Error: Syntax error. Found ')' "
jpizzalajpizzala
Looks like you have an extra comma in there. Try this:

Code:
IF( Case_Age__c > 20, 
IMAGE("/img/samples/color_red.gif", "red", 30, 30),
IF( Case_Age__c > 10,
IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30),
IMAGE("/img/samples/color_green.gif", "green", 30, 30)
) )
 
geis6geis6
Thanks Jason,  I tried this:
IF( HasCommentsUnreadByOwner = true,
IMAGE("/img/samples/color_red.gif", "red", 30, 30),
IF( HasCommentsUnreadByOwner = false,
IMAGE("/img/samples/color_green.gif", "green", 30, 30),
IMAGE(("/img/samples/color_yellow.gif", "yellow", 30, 30)
) )

I still got an error:

Error: Syntax error. Missing ')'


Cheers,
Ward

Edit, never mind I got it to validate.  Notice extra "(" on 3rd IMAGE?


Message Edited by geis6 on 05-20-2008 04:39 PM
jpizzalajpizzala
Now you have an extra open parenthesis :smileyhappy:
Here is the code with the extra "(" removed from the IMAGE tag:

Code:
IF( HasCommentsUnreadByOwner = true,
IMAGE("/img/samples/color_red.gif", "red", 30, 30),
IF( HasCommentsUnreadByOwner = false,
IMAGE("/img/samples/color_green.gif", "green", 30, 30),
IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30)
) )

 

geis6geis6
Here is the final code for an image field that shows a red flag when a case has a new comment that is unread by the case owner.  I use this within case views or in the console to alert my analysts to cases that have been updated.

IF( HasCommentsUnreadByOwner = True,
IMAGE("/img/samples/flag_red.gif", "red"),
IMAGE("/s.gif", "")
)

Cheers,
Ward