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
aparkmanaparkman 

Image Formula field referenced in Visualforce page

Hello,

I have an image formula field on Case which is showing one of the standard Salesforce flags (grren, yellow, or red) based on the time remaining on when the case should be resolved The formula for this field is below:

IMAGE(
IF((Minutes_to_Deadline__c > (SLA_Minutes_2__c * 0.25)),"/img/samples/flag_green.gif",
IF(Minutes_to_Deadline__c < 0, "/img/samples/flag_red.gif",

IF((Minutes_to_Deadline__c > 0 && Minutes_to_Deadline__c <=(SLA_Minutes_2__c * 0.25)) , "/img/samples/flag_yellow.gif",""

))),"None")


I am now trying to reference this field in a Visualforce page in the case console. I am able to save the page with this field in the code, but when I open the console and look at the component which is built from the visualforce page, it outputs the url of image (e.g. "/img/samples/flag_red.gif") instead of the image. I believe this was because I had "apex:outputText" in the code:

<apex:outputText value="{!con1.Case_SLA__c}"/>

I then changed this to be (although i know I'm missing something):

<apex:image id="flag" value="{!con1.Case_SLA__c}"/>

It now only shows a broken image.
User-added image
Does anyone know how I can get this to show the flag that is in the formula field? Or do I have to put logic in either the Visualforce page or Controller to show what I want it to show?

Thanks,
Adam
 
Best Answer chosen by aparkman
kaustav goswamikaustav goswami
Can ypu please try with <apex:inputField value="{!con1.Case_SLA__c}" /> or with <apex:outputField value="{!con1.Case_SLA__c}" />. Any one of these should work.

Thanks,
Kaustav

All Answers

kaustav goswamikaustav goswami
Can ypu please try with <apex:inputField value="{!con1.Case_SLA__c}" /> or with <apex:outputField value="{!con1.Case_SLA__c}" />. Any one of these should work.

Thanks,
Kaustav
This was selected as the best answer
Dushyant SonwarDushyant Sonwar
Hi aparkman,
Did you try out with this also?


<apex:image id="flag" url="{!con1.Case_SLA__c}"/>
 
SaranshSaransh
Try this:
 
<apex:outputText value="{!con1.Case_SLA__c}" escape="false"/>

 
aparkmanaparkman
Thanks for the responses everyone! I modified it to be <apex:outputField value="{!con1.Case_SLA__c}" />, and it is now working.

Saransh - what does thes escape="false" do with it?
SaranshSaransh
When you "escape" the values, they are converted to an HTML-compliant representation, for instance: 
- < will become &lt; 
- > will become &gt; 
- & will become &amp; 
- etc. 

When you disable this with 'escape="false"' then this conversion won't happen.
Jessica LayJessica Lay
Can an image formula field be merged into an html email template?  The image does not seem to render when the email is generated from a workflow.