+ Start a Discussion

Conditionally Render Image on Visualforce Page Based on Field Value

Hello Community- seasoned Admin, but beginner developer here!

I'm building a Visualforce page that will serve as the default landing page for my Salesforce Community, and as a personal touch would like to display a nice welcome message and content that would render dynamically, based on who is logging in.  As far as merge fields go, I'm all set.

However where I'm getting stuck is to conditionally display a set of images stored in Documents, based on the Current User's value in the Company field({!$User.CompanyName}).

I've attempted to write logic using IF/ELSE IF/ELSE commands, however it's just not rendering correctly.  In short, here's what I'm trying to achieve:

If User's Company Name = 'Company 1', display Logo 1
If User's Company Name = 'Company 2', display Logo 2
..and so on..
...and so on...
....Else, display nothing

Thanks in advance for any suggestions you can provide!
karthikeyan perumalkarthikeyan perumal

kindly look at the sample code. user rendered attribute like blow
<apex:form >
<apex:image url="/servlet/servlet.FileDownload?file={!logoid1}" rendered="{!IF(CompanyName ="Name1",true,false)}"\>
<apex:image url="/servlet/servlet.FileDownload?file={!logoid2}" rendered="{!IF(CompanyName ="Name2",true,false)}"\>
<apex:image url="/servlet/servlet.FileDownload?file={!logoid3}" rendered="{!IF(CompanyName ="Name3",true,false)}"\>
<apex:image url="/servlet/servlet.FileDownload?file={!logoid4}" rendered="{!IF(CompanyName ="Name4",true,false)}"\>

Hope this will help you, Mark Best ANSWER if its work for you. 

    <apex:form >
        <apex:image id="theImage" 
                    "value="{!IF(Company==A,$Resource.SRC_Image_Name_For_A, IF(Company==B,$Resource.SRC_Image_Name_For_B,$Resource.SRC_CommonImage_Name_For_All))}" 
use if/else and also put a common image for whom any image not available.
farah johnfarah john
Its an online survey feedback platform offered by Kroger ... Next, you need to have made a purchase on any of the kroger store within 7 days ...
kroger-feedback (http://kroger-feedback.us/)