0
votes

I am new to salesforce development. I have a requirement where not much customozation is needed but need to hide or show a couple of fields based on a value of other field. Can I do this using standard controller and adding an extension controller? if yes How? e.g I need to show the standard account page with list of accounts. when I click on a account , on the standard detail page there is a field " Rate". if the Rate is below 10% then I have to show "Revenue " field and if its >10% then I have to hide the previous field and show "Approx. Revenue" field. Is this possible? THnaks

1

1 Answers

0
votes

I assume you're talking about Visualforce page and not the standard page layout? (It should be doable also with standard page layouts but would require some record type juggling, assigning of rec type depending on your conditions)...

It's possible to do what you want in pure Visualforce (just the standard controller, no extension). Do you want to display one account or multiple(in some table?)

Roughly speaking you should read about rendered attribute available on most visualforce tags. Here's a sample based on Opportunities but the principle is the same.

<apex:page standardController="Opportunity" recordSetVar="opps" readonly="true">
<apex:pageBlock>
    <apex:pageBlockTable value="{!opps}" var="o">
        <apex:column value="{!o.Name}" />
        <apex:column value="{!o.Probability}" />
        <apex:column headerValue="Amount or Stage">
            <apex:outputField value="{!o.StageName}" rendered="{!o.Probability != 100}" />
            <apex:outputField value="{!o.Amount}" rendered="{!o.Probability = 100}" />
        </apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

enter image description here