I have a requirement where I have to display different pages depending on a Lead's custom field's (Score__c) value. Kindly help me with a sample code which states that if the value of Score__c is 'A', display /apex/PageA and If value of Score__c is 'B' then display /apex/PageB.
Here is the Controller:
public PageReference getScoreA () {
PageReference pageRef = new PageReference( '/apex/PageA' );
pageRef.setRedirect( true );
return pageRef;
}
public PageReference getScoreB () {
PageReference pageRef = new PageReference( '/apex/PageB' );
pageRef.setRedirect( true );
return pageRef;
}
public PageReference ViewProposal() {
PageReference pageRef = null;
List<Lead> LeadList = [Select id, Name ,Score__c FROM Lead];
if (record.Score__C== 'A' {
pageRef = this.getScoreA();
} else if (record.Score== 'B' {
pageRef = this.getScoreB();
}
return pageRef;
}
Page-
<apex:pageBlock>
<apex:pageblockButtons>
<apex:commandButton title="Submit" action="{!ViewProposal}" value="Submit" />
</apex:pageblockButtons>
</apex:pageBlock>