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
Andrew NorthAndrew North 

Display an image within a Visualforce Section dependent on Opportunity Record Type.

Hi

We have a visualforce section on all of our Opportortunity page layouts.
This section shows a particular image depending on what has been selected within the stage field.
Below is a sample of the code that we have in place.
Is it possible to split it up so that depending on which Opportunity Record Type is selected different images can be displayed against each stage?

For example if record type = X and the stage is Closed Won then show image A
If record type = Y and the Stage is closed Won then show image B

Thank you
 
<apex:page standardController="Opportunity" showHeader="true" sidebar="true">

<div align="center">

></apex:image> <apex:image id="won" value="{!$Resource.stageWon}" height="60" rendered="{!Opportunity.stageName = 'Closed Won'}"

 ></apex:image> <apex:image id="lost" value="{!$Resource.stageLost}" height="60" rendered="{!Opportunity.stageName = 'Closed Lost'}" 

</div>

</apex:page>

 
Best Answer chosen by Andrew North
mukesh guptamukesh gupta
Hello Andrew

Please use my tested  code :- 
 
<apex:page standardController="Opportunity" showHeader="true" sidebar="true">

<div align="center">

<apex:image id="won" value="{!$Resource.stageWon}" height="60" rendered="{!IF(AND(Opportunity.RecordType.Name == 'X',Opportunity.stageName == 'Closed Won'), TRUE, FALSE)}"></apex:image> 

<apex:image id="lost" value="{!$Resource.stageLost}" height="60" rendered="{!IF(AND(Opportunity.RecordType.Name == 'Y',Opportunity.stageName == 'Closed Lost'), TRUE, FALSE)}"></apex:image>  

</div>

</apex:page>

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 

All Answers

badibadi
Hello Andrew,

Use <apex:outputpanel> to do that

E.g.: 
<apex:page>

<apex:outputPanel id="recType1" rendered="{!x.RecordType.Name == 'apples''}" >

<apex:image id="won" >
<apex:image id="lose">

</apex:outputPanel>

<apex:outputPanel id="recType2" rendered="{!x.RecordType.Name == 'oranges''}" >

<apex:image id="won" >
<apex:image id="lose">

</apex:outputPanel>


</apex:page>

Hope this helps
badibadi
sorry, there is an extra '. Current Syntax is, 
{!x.RecordType.Name == 'apples'}
mukesh guptamukesh gupta
Hello Andrew

Please use my tested  code :- 
 
<apex:page standardController="Opportunity" showHeader="true" sidebar="true">

<div align="center">

<apex:image id="won" value="{!$Resource.stageWon}" height="60" rendered="{!IF(AND(Opportunity.RecordType.Name == 'X',Opportunity.stageName == 'Closed Won'), TRUE, FALSE)}"></apex:image> 

<apex:image id="lost" value="{!$Resource.stageLost}" height="60" rendered="{!IF(AND(Opportunity.RecordType.Name == 'Y',Opportunity.stageName == 'Closed Lost'), TRUE, FALSE)}"></apex:image>  

</div>

</apex:page>

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 
This was selected as the best answer
Andrew NorthAndrew North

That worked perfectly Mukesh!

Thank you so much!