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
Frank TimmonsFrank Timmons 

Save and Edit button on a VF Page used as a section

I'm in need of some assistance with getting the "Save" and "Edit" buttons to act how I need them to act on a VF Page.

Because SF limits you to just two columns in a Section, I had to create a VF page to create 3 columns.  But the problem I'm running into is what happnens after I click the "Save" or "Edit" buttons.  The VF Page is just one section on the Account Page Layout, but when I click either one of those buttons, the Section will refresh and display the entire Account Page Layout and not just the VF page.  What am I missing?  How does the code need to be written so it only shows the VF page?  I hope I'm explaining this clearly.

Here is the code:
<apex:page standardController="Account">
   <apex:form >
      <apex:pageBlock >
        
        <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!edit}" value="Edit"/>
                <apex:commandButton action="{!cancel}" value="Cancel" />
        </apex:pageBlockButtons>
                
                <apex:pageBlockSection columns="3" collapsible="true">
                                            
                <apex:outputLabel ><strong> </strong></apex:outputLabel>
                <apex:outputLabel ><strong><U> Modules </U></strong></apex:outputLabel>
                <apex:outputLabel ><strong><U> Champion </U></strong></apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_504__c}"/>
                <apex:outputField value="{!Account.moduleActive_504__c}"/>
                <apex:outputLabel > Rudy </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_Cafeteria__c}"/>
                <apex:outputField value="{!Account.moduleActive_Cafeteria__c}"/>
                <apex:outputLabel > Jacquie, Charles </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_Gradebook__c}"/>
                <apex:outputField value="{!Account.moduleActive_Gradebook__c}"/>
                <apex:outputLabel > Linda C. </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_IRS__c}"/>
                <apex:outputField value="{!Account.moduleActive_IRS__c}"/>
                <apex:outputLabel > Rudy </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_LessonPlanner__c}"/>
                <apex:outputField value="{!Account.moduleActive_LessonPlanner__c}"/>
                <apex:outputLabel > Linda C. </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_Notification__c}"/>
                <apex:outputField value="{!Account.moduleActive_Notification__c}"/>
                <apex:outputLabel > Stacy </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_ParentPortal__c}"/>
                <apex:outputField value="{!Account.moduleActive_ParentPortal__c}"/>
                <apex:outputLabel > Stacy </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_StudentPortal__c}"/>
                <apex:outputField value="{!Account.moduleActive_StudentPortal__c}"/>
                <apex:outputLabel > Stacy </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_SGO__c}"/>
                <apex:outputField value="{!Account.moduleActive_SGO__c}"/>
                <apex:outputLabel > Lindsey, Tracy </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_SIS__c}"/>
                <apex:outputField value="{!Account.moduleActive_SIS__c}"/>
                <apex:outputLabel > Kim </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_SLIM__c}"/>
                <apex:outputField value="{!Account.moduleActive_SLIM__c}"/>
                <apex:outputLabel > Larry </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_SpecialEd__c}"/>
                <apex:outputField value="{!Account.moduleActive_SpecialEd__c}"/>
                <apex:outputLabel > Kenton, Kellee </apex:outputLabel>
                
                <apex:outputField value="{!Account.modulePO_StaffEvaluation__c}"/>
                <apex:outputField value="{!Account.moduleActive_StaffEvaluation__c}"/>
                <apex:outputLabel > Lindsey, Tracy </apex:outputLabel>
                
                </apex:pageBlockSection> 
        </apex:pageBlock> 
  </apex:form>
</apex:page>
Best Answer chosen by Frank Timmons
William TranWilliam Tran
Do you want this screen to override the current out of the box edit button?  

If yes,  go to setup/build/customize/accounts/buttons, links and actions

Click edit on the "Edit" button and choose override with Visualforce page the choose your page.

Now, when you edit your account, your new VF 3 column page will show up instead of the out of the box one.

Thx

All Answers

William TranWilliam Tran
Do you want this screen to override the current out of the box edit button?  

If yes,  go to setup/build/customize/accounts/buttons, links and actions

Click edit on the "Edit" button and choose override with Visualforce page the choose your page.

Now, when you edit your account, your new VF 3 column page will show up instead of the out of the box one.

Thx
This was selected as the best answer
Frank TimmonsFrank Timmons
That sort of worked.  But it's really the "Save" button that when clicked, that it displays the VF Section as it did before.

Here is the Account Page Layout before clicking the Save button
User-added image


Here is the Account Page Layout after clicking the Save button
User-added image
William TranWilliam Tran
is Save District Module a VF page?  Where is the code for that?

Show me the page code (and controller if there is one), and if all goes to plan, I will show you the solution :-)

It looks to be embedded in the standard page.


Your page only has: Save/Edit/Cancel buttons

        <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!edit}" value="Edit"/>
                <apex:commandButton action="{!cancel}" value="Cancel" />
        </apex:pageBlockButtons>

​Thx
Frank TimmonsFrank Timmons
Okay I got it..I had to create two VF pages.  One that is displayed on the Account Page layout without any buttons, then a second VF page to be soleley used when clicking the Edit button as you suggested earlier.

Now, my last question is, how do I control the column width?

<apex:page standardController="Account">
   <apex:form >
      <apex:pageBlock >
    
         <apex:pageBlockSection title="Account Details" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.phone}"/>
                <apex:inputField value="{!account.Account_URL__c}"/>
                <apex:inputField value="{!account.fax}"/>
                <apex:inputField value="{!account.website}"/>
                <apex:inputField value="{!account.Phone_PIN_Not_Required__c}"/>
         </apex:pageBlockSection>
         
         <apex:pageBlockSection columns="1">  
                <apex:inputField value="{!account.District_Security_Admin__c}"/>
                <apex:inputField value="{!account.Account_Background_Notes__c}"/>
                <apex:inputField value="{!account.Description}"/>
                <apex:inputField value="{!account.Core_Scheduled_Event_Details__c}"/>
                <apex:inputField value="{!account.SpEd_Scheduled_Event_Details__c}"/>   
         </apex:pageBlockSection>
                
         <apex:pageBlockSection columns="3">
                <apex:outputLabel ><strong> </strong></apex:outputLabel>
                <apex:outputLabel ><strong><U> Modules </U></strong></apex:outputLabel>
                <apex:outputLabel ><strong><U> Champion </U></strong></apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_504__c}"/>
                <apex:outputField value="{!Account.moduleActive_504__c}"/>
                <apex:outputLabel > Rudy </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_Cafeteria__c}"/>
                <apex:outputField value="{!Account.moduleActive_Cafeteria__c}"/>
                <apex:outputLabel > Jacquie, Charles </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_Gradebook__c}"/>
                <apex:outputField value="{!Account.moduleActive_Gradebook__c}"/>
                <apex:outputLabel > Linda C. </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_IRS__c}"/>
                <apex:outputField value="{!Account.moduleActive_IRS__c}"/>
                <apex:outputLabel > Rudy </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_LessonPlanner__c}"/>
                <apex:outputField value="{!Account.moduleActive_LessonPlanner__c}"/>
                <apex:outputLabel > Linda C. </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_Notification__c}"/>
                <apex:outputField value="{!Account.moduleActive_Notification__c}"/>
                <apex:outputLabel > Stacy </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_ParentPortal__c}"/>
                <apex:outputField value="{!Account.moduleActive_ParentPortal__c}"/>
                <apex:outputLabel > Stacy </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_StudentPortal__c}"/>
                <apex:outputField value="{!Account.moduleActive_StudentPortal__c}"/>
                <apex:outputLabel > Stacy </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_SGO__c}"/>
                <apex:outputField value="{!Account.moduleActive_SGO__c}"/>
                <apex:outputLabel > Lindsey, Tracy </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_SIS__c}"/>
                <apex:outputField value="{!Account.moduleActive_SIS__c}"/>
                <apex:outputLabel > Kim </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_SLIM__c}"/>
                <apex:outputField value="{!Account.moduleActive_SLIM__c}"/>
                <apex:outputLabel > Larry </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_SpecialEd__c}"/>
                <apex:outputField value="{!Account.moduleActive_SpecialEd__c}"/>
                <apex:outputLabel > Kenton, Kellee </apex:outputLabel>
                
                <apex:InputField value="{!Account.modulePO_StaffEvaluation__c}"/>
                <apex:outputField value="{!Account.moduleActive_StaffEvaluation__c}"/>
                <apex:outputLabel > Lindsey, Tracy </apex:outputLabel>
         </apex:pageBlockSection>
        
         <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel" />
         </apex:pageBlockButtons>
      
      </apex:pageBlock> 
   </apex:form>
</apex:page>