1

I had an image formula field running off a picklist that had fixed values 1,2,3,4,5. The formula worked and showed a red, amber, green, light blue, or dark blue image respectively. To make the picklist more meaningful, I changed the numbers to words. My Image formula stopped working. I tried with and without ISPICKVAL(), TEXT() and nothing before Support_level__c. Nothing happening.

IMAGE(
  CASE( ISPICKVAL(Support_Level__c ,
    "Intensive Support", "/servlet/servlet.FileDownload?file=0150g000002vla0",
    "Middle Range Support", "/servlet/servlet.FileDownload?file=0150g000002vla5",
    "Some Support and Stable", "/servlet/servlet.FileDownload?file=0150g000002vlaF",
    "Little Support and Stable", "/servlet/servlet.FileDownload?file=0150g000002vlaA",
    "Ready to move on", "/servlet/servlet.FileDownload?file=0150g000002vlaA",
    "Undefined")),
"Undefined")

I then tried a work around! Lightbulb. I created a number field which was updated by a workflow according to what the Support_Level__c values was.

IMAGE(
  CASE(Update_Traffic_Number__c,
    1, "/servlet/servlet.FileDownload?file=0150g000002vla0",
    2, "/servlet/servlet.FileDownload?file=0150g000002vla5",
    3, "/servlet/servlet.FileDownload?file=0150g000002vlaF",
    4, "/servlet/servlet.FileDownload?file=0150g000002vlaA",
    5, "/servlet/servlet.FileDownload?file=0150g000002vlaA",
    "Undefined")),
"Undefined")

Still no joy. The number field was not updating so I could not test this formula. I made number formula field to see if that would help. Nope. It did not update. There is something in the Support_Level__C field that I am not translating through anymore.

The other versions I have played with (using the traffic light formula field):

CASE( Traffic_Light_No__c ,
    1, IMAGE("/servlet/servlet.FileDownload?file=0150g000002vla0","Red"),
    2, IMAGE("/servlet/servlet.FileDownload?file=0150g000002vla5", "Amber"),
    3, IMAGE("/servlet/servlet.FileDownload?file=0150g000002vlaF", "Green"),
    4, IMAGE("/servlet/servlet.FileDownload?file=0150g000002vlaA", "Light Blue"),
    5, IMAGE("/servlet/servlet.FileDownload?file=0150g000002vlaA", "Dark Blue"),
    "Undefined")

And this:

IF( (ISPICKVAL(Support_Level__c, "Intensive Support")), (IMAGE("/servlet/servlet.FileDownload?file=0150g000002vla0", "Red")),
IF( (ISPICKVAL(Support_Level__c, "Middle Range Support")), IMAGE("/servlet/servlet.FileDownload?file=0150g000002vla5", "Amber"),
IF( (ISPICKVAL(Support_Level__c, "Some Support and Stable")), IMAGE("/servlet/servlet.FileDownload?file=0150g000002vlaF", "Green"),
IF( (ISPICKVAL(Support_Level__c, "Little Support and Stable")), IMAGE("/servlet/servlet.FileDownload?file=0150g000002vlaA", "Light Blue"),
IF( (ISPICKVAL(Support_Level__c, "Ready to move on")), IMAGE("/servlet/servlet.FileDownload?file=0150g000002vlaA", "Dark Blue"),
"Undefined")))))

I think I have now been looking at this so long I can't see my way!

0

your first variant was almost correct. The only problem is that you used wrong formula to define text value of picklist field. According to Formula Operators and Functions documentation

ISPICKVAL - Determines if the value of a picklist field is equal to a text literal you specify.

Correct formula is TEXT

TEXT - Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links.

So your proper formula is:

IMAGE(
    CASE(
        TEXT(Support_Level__c),
        "Intensive Support", "/servlet/servlet.FileDownload?file=0150g000002vla0",
        "Middle Range Support", "/servlet/servlet.FileDownload?file=0150g000002vla5",
        "Some Support and Stable", "/servlet/servlet.FileDownload?file=0150g000002vlaF",
        "Little Support and Stable", "/servlet/servlet.FileDownload?file=0150g000002vlaA",
        "Ready to move on", "/servlet/servlet.FileDownload?file=0150g000002vlaA",
        "Undefined"
    ),
    "Undefined"
)

In addition, I recommend you to load that images as static resource. This will allow you to have it working on sandboxes as well, as in this case you've just hardcoded ids of uploaded documents. Lets say, you created one zip archive names SupportLevelIcons with images named in the following way:

  • IntensiveSupport.png
  • MiddleRangeSupport.png
  • SomeSupportAndStable.png
  • LittleSupportAndStable.png
  • ReadyToMoveOn.png

then your formula will look like:

IMAGE(
    CASE(
        TEXT(Support_Level__c),
        "Intensive Support", "/resource/SupportLevelIcons/IntensiveSupport.png",
        "Middle Range Support", "/resource/SupportLevelIcons/MiddleRangeSupport.png",
        "Some Support and Stable", "/resource/SupportLevelIcons/SomeSupportAndStable.png",
        "Little Support and Stable", "/resource/SupportLevelIcons/LittleSupportAndStable.png",
        "Ready to move on", "/resource/SupportLevelIcons/ReadyToMoveOn.png",
        "Undefined"
    ),
    "Undefined"
)
  • Thank you for getting back so quickly! I can now see my images (as a static resource. However when "Intensive Support" is selected, they receiving "Undefined" in the Image formula. IMAGE( CASE( TEXT(Support_Level__c), "Intensive Support", "/resource/1523523914000/Red", "Middle Range Support", "/resource/1523523994000/Yellow", "Some Support and Stable", "/resource/1523523865000/Green", "Little Support and Stable", "/resource/1523523705000/Blue", "Ready to move on", "/resource/1523523790000/DarkBlue", "/resource/1523523955000/Undefined" ), "/resource/1523523955000/Undefined" ) – Rebecca Apr 12 '18 at 9:10
  • @Rebecca you need to include image extension too, as I showed you in example. "/resource/SupportLevelIcons/MiddleRangeSupport.png" – Oleksandr Berehovskyi Apr 12 '18 at 9:12
  • Apologies - now added .gif at the end of all the image references. I still get the "Undefined.gif" result when I should be getting red for "intensive support". – Rebecca Apr 12 '18 at 9:14
  • I added a zip with some .gif images instead of png. – Rebecca Apr 12 '18 at 9:48
  • what is a name of that static resource? – Oleksandr Berehovskyi Apr 12 '18 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.