+ Start a Discussion
heatherwebsterheatherwebster 

Imaged Formula Field Not Displaying Properly

Is it possible to have an imaged formula field display on a Visualforce Page? 
 
If so where do the images need to be stored (I've tried both Documents and Static Resources)?  And what component and attribute do you use to display it?  Output field Value displays the url and not the actual image.  The formula is valid and it does display on a traditional SF page.  
 
Thanks,
Heather
dchasmandchasman
Not currently supported. There is a known issue with the handling of custom formula fields that use the IMAGE() function. The workaround is to use <apex:image> and urlFor() directly in your VF page's markup.
heatherwebsterheatherwebster
Doug  -

I am new to Visualforce so I apologize but could really use some help.  What am I doing wrong or is there a better way to do this.  I am trying to choose one or the other picture based on some condition.  I am having trouble actually calling the function in my extension from my Visualsource page.  Any help would be appreciated, thanks.

 

 

 

<apex:page standardController="Gold_Sheet__c" extensions="myExtension">     

<apex:image url= ‘{!GetURL()}’ />

 </apex:page>

 

 public class myExtension
{
public static string GetURL()
{
      if(User.FirstName == null)
      {

            return '{!$Resource.Red_Flag}';
      }

      else
      {

            return '{!$Resource.Blue_Flag}';

      }
}

}

jwetzlerjwetzler
I think you need to take a look at the documentation on custom controllers for property syntax.

<apex:image url="{!url}"/>

public String getUrl() {
  return 'http://www.google.com/somePicture.gif';
}

You should also review the documentation for $Resource and Static Resources, because you can't use $Resource within a controller, that is a formula function that you can only use on your page.

<apex:image url="{!IF(ISNULL(User.firstname), URLFOR($Resource.image1), URLFOR($Resource.image2))}"/>

where you have a getUser method defined in your controller that returns a User object with firstname selected.
BigGeoBigGeo

I was able to do it with outputText and specifying escape parameter as false:

 

<apex:outputText value="{!Object.ImageFormulaField__c}" escape="false"/>

sausalito devsausalito dev

For a Google URL, like the one above, don't forget to set the remote site settings for URLs outside of Salesforce in Your Name | Setup | Security Controls | Remote Site Settings.