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
ckellieckellie 

Dynamic Editing - Using Multiple Variables

Based on the Dynamic Editing visualforce example, I am needing todisplay one of two fields depending on the picklist value. The field is "Create a New Account?" If the answer is yes, the Account Name text field will appear. If the answer is no, Account Name Lookup field will appear. Currently, here is my code for the specific section of the page:

 

apex:pageBlockSection title="Required Account Information" id="thePageBlock" columns="1">
            <apex:pageMessages />

            <apex:actionRegion >
                <apex:pageBlockSection columns="1">
                   
                    <apex:pageBlockSectionItem >
                      <apex:outputLabel value="Create A New Account?"/>
                        <apex:outputPanel >
                            <apex:inputField value="{!Account.Create_A_New_Account__c}" required="true">
                                <apex:actionSupport event="onchange" rerender="thePageBlock"
                                                    status="status"/>
                            </apex:inputField>
                            <apex:actionStatus startText="applying value..." id="status"/>
                        </apex:outputPanel>
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
            </apex:actionRegion>
            <apex:pageBlockSection columns="1"
                                   rendered="{!Account.Create_A_New_Account__c == 'Yes'}">
               <apex:inputField value="{!Account.Name}"/>
            </apex:pageBlockSection>

                <apex:inputField value="{!Opportunity.AccountID}"/>
          
            </apex:pageBlockSection>

 

Also, how do I customize the controller to create or retrieve the account?

 

Here is that code:

 

    public Account getAccount() {
        if(account == null) account = new Account();
        return account;

sfdcElephantsfdcElephant

Its very good example.

Can u share the total code

 

Thanks