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
nasir jawednasir jawed 

How to Display Image in VF page using controller

Hi

 

I have created a formula field using CASE and in that i am diaplaying image in a custom object called QUOTA.I can see the Image.But i the customer want to see the image in a VF page.

 

My formula field is called MonDr and its formula is 

 

MonDr =IF(Monday_Achievement__c < Monday_Quota__c , "Black",IF(Monday_Achievement__c > Monday_Quota__c,"Red",IF(Monday_Achievement__c == Monday_Quota__c,"Yellow",null)))

 

and i am displaying this image by using CASE

 

MonDrImage(text)=IMAGE(CASE( MonDr__c , "Black"," /servlet/servlet.ImageServer?id=015O00000004oBU&oid=00DO00000005GiK&lastMod=1315504942000","Yellow","/servlet/servlet.ImageServer?id=015O00000004oBe&oid=00DO00000005GiK&lastMod=1315504988000","Red","https://c.cs5.content.force.com/servlet/servlet.ImageServer?id=015O00000004oBZ&oid=00DO00000005GiK&lastMod=1315504968000",""),"",30,30)

 

As i can see the image in page layout when the following condition are meet.

 

How can i dispay the same image in VF page????

 

As i had created the VF page and controller for this

<apex:page showHeader="false" controller="DataRepresentation" extensions="DataRepresentation">
    <center>
    <u>    
    <h1>My Data Representation</h1>
    </u>
    <br></br>
    
   
    <apex:pageBlock >
    <apex:pageBlockTable value="{!display}" var="dis">
     <apex:outputLabel >Monday:</apex:outputLabel>  
    <apex:outputText value="{!dis.MonDrImage__c}" escape="false"/>
    </apex:pageBlockTable>    
    </apex:pageBlock>
    
    </center>
</apex:page>

 The apex class is :

public class DataRepresentation {

  public Quotas__c q{get; set;}
  public String s;
  
  public Quotas__c getdisplay(){
        
        Id usrId = UserInfo.getUserId();
        Goals__c g =[Select id from Goals__c where User__c=:usrId];
        if(q!=null){
            q =[select MonDrImage__c,Monday_Quota__c from Quotas__c where 
                Week_of__c =: System.Today().toStartofWeek()
                and RecordTypeId=:Utility.getRecordTypeId('Daily')
                and Quota_For__c='Leads CY'
                and Goal__c=:g.Id limit 1
               ]; 
            }
             //System.debug('image:'+ q.Monday_Quota__c); 
        
        
              return q;
    }
   
   


}

 

:Please help me how can i display that formula field in VF page for Monday Quota

 

Thanks

 

Nasir

goabhigogoabhigo

Instead of outputTex use <apex:outputField>. Does it work??