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
AndyuxAndyux 

image picklist formula returns value, not image

The fromula seems to be working, but its displaying
"<img src="/servlet/servlet.FileDownload?file=0151600000QNE8V" alt=" " border="0"/>"
Instead of the image. Seems like a need URL reference?

This is the code on VF page to display picklist
<apex:outputField value="{!customo__c.Flag__c}" >    
    <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
    hideOnEdit="editButton" event="ondblclick" 
    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
and field Flag__c is picklist "Green" , "Red"

This is the code on VF page to display image
{!customo__c.Flag_formula__c}
This is the fromula (text) for field "Flag_formula__c"
IMAGE(
CASE(Flag__c,
"Green","/servlet/servlet.FileDownload?file=0151600000QNE8V",
"Red","/servlet/servlet.FileDownload?file=0151600000QNE8f",
""),"")
The images URL work
https://c.na23.content.force.com/servlet/servlet.FileDownload?file=0151600000QNE8V
https://c.na23.content.force.com/servlet/servlet.FileDownload?file=0151600000QNE8f


 
Best Answer chosen by Andyux
Shashikant SharmaShashikant Sharma

Ok Now I understand what is the issue. You just need to add an IF Condition to your formula to show image only if Flag is not blank.
 
IF( TEXT(Flag__c) == '', 'No Image', 
    IMAGE( CASE(Flag__c, 
           "Green","/servlet/servlet.FileDownload?file=0151600000QNE8V", 
           "Red","/servlet/servlet.FileDownload?file=0151600000QNE8f", 
           "Green Flag"),"Red Flag") 
   )

Right now if have used text no image if Flag is ablank you could change according to your need.

This will fix your issue.

Thanks
Shashikant

All Answers

AndyuxAndyux
This is the code on VF page to display image
<apex:image url="{!StrategicSales__c.Flag_formula__c}" />
Gettting a broken image icon. HTML is rendering the image URL as
https://c.na23.visual.force.com/apex/%3Cimg+src=%22/servlet/servlet.FileDownload?file=0151600000QNE8V%22%20alt=%22Red%20Flag%22%20border=%220%22/%3E
Anyone?

 
Shashikant SharmaShashikant Sharma
Hi Andyux,

I order to show the Image on Visualforce Page you have to use outbput:Field like you have used for Flag__c field like below.
 
<apex:outputField value="{!customo__c.Flag_formula__c}">
This will fix your issue.

Let me know if you still face issue.

Thanks
Shashikant
 
AndyuxAndyux
I thought i tried that, thanks! red and green flags show - but when picklist is --none-- nothing selected, i get a broken image icon.
IMAGE(
CASE(Flag__c,
"Green","/servlet/servlet.FileDownload?file=0151600000QNE8V",
"Red","/servlet/servlet.FileDownload?file=0151600000QNE8f",
"Green Flag"),"Red Flag")
How do i specify for no valuse selected, do nothing? I tried null, else?
 
Shashikant SharmaShashikant Sharma

Ok Now I understand what is the issue. You just need to add an IF Condition to your formula to show image only if Flag is not blank.
 
IF( TEXT(Flag__c) == '', 'No Image', 
    IMAGE( CASE(Flag__c, 
           "Green","/servlet/servlet.FileDownload?file=0151600000QNE8V", 
           "Red","/servlet/servlet.FileDownload?file=0151600000QNE8f", 
           "Green Flag"),"Red Flag") 
   )

Right now if have used text no image if Flag is ablank you could change according to your need.

This will fix your issue.

Thanks
Shashikant
This was selected as the best answer