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
forceoneforceone 

Color value not displayed in VF

Hi:
I would like to display status color on custom VF page. I defined a color field as a formula text. 
The color field displays right color in standard object screen. It does not work when I tried to use the same field in Visualforce.
 The code is given below
<apex:page standardController="Project__c" recordSetVar="projects">
<apex:pageBlock >    
<apex:form id="theForm">         
<apex:pageBlockTable value="{!projects}" var="prj">
             <apex:column value="{!prj.name}"/>
            <apex:column headerValue="Scope">
             <apex:outputField value="{!prj.Scope_Color__c}"/> 
           </apex:column>            
</apex:pageBlockTable>
     </apex:form>
</apex:pageBlock>
</apex:page>
The display shows the value <img src="/img/samples/color_yellow.gif" alt="Yellow" height="10" width="10" border="0"/>
instead of the yellow color.
I appreciate any help.

Hi:
I would like to display status color on custom VF page. I defined a color field as a formula text. The color field displays right color in standard object screen. It does not work when I tried to use the same field in Visualforce. The code is given below
<apex:page standardController="Project__c" recordSetVar="projects">

<apex:pageBlock >  

 <apex:form id="theForm">         

<apex:pageBlockTable value="{!projects}" var="prj">            

<apex:column value="{!prj.name}"/>            

<apex:column headerValue="Scope">            

<apex:outputField value="{!prj.Scope_Color__c}"/>           

</apex:column>            

</apex:pageBlockTable>    

</apex:form>

</apex:pageBlock>

</apex:page>


The display shows the value <img src="/img/samples/color_yellow.gif" alt="Yellow" height="10" width="10" border="0"/>instead of the yellow color.
I appreciate any help.

SFDummySFDummy

Once you get the URL of the color use it in image tag to display in VF page

 

like the following if stored as document

 

<apex:image url="/servlet/servlet.FileDownload—file={!document.id}" />

 

 

or like if stored as static resource

 

<apex:image url="{!URLFOR($Resource.Images, '/img/samples/color_yellow.gif')}"/>

 

 

forceoneforceone

Hi:

 

I defined the formula text value as

IF(ISPICKVAL(En__Dependency_Health__c,  "Green - No impact"), IMAGE("/img/samples/color_green.gif", "green", 10, 10),
IF(ISPICKVAL(En__Dependency_Health__c,  "Yellow - Some impact"),IMAGE("/img/samples/color_yellow.gif", "Yellow", 10, 10),
IF(ISPICKVAL(En__Dependency_Health__c,  "Red - Severe impact"),IMAGE("/img/samples/color_red.gif", "Red", 10, 10),
" ")))

 

The color appears fine when I display the field as part of object.

 

Now, I want to refer that formula value in my VF page and I get the text string. The static resource method works if I am referring to an image directly.

 

Thanks.