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
Karen YetterKaren Yetter 

Visualforce section returns entire page on Save

I have added a visualforce page w/ tabs as a section on an account page. Records can be updated. \

section with tabs

However, when I hit the save button, it brings up the entire salesforce page within the section. How can I have it return the original visualforce page in the sectionpage within a section?
Best Answer chosen by Karen Yetter
VaasuVaasu
Can you use commandlink instead of button? One like below, this will fix the issue but renders as link instead of button. You can use CSS to make it look like button.
<apex:commandlink action="{!save}" value="Save" target="_top"/>

All Answers

Karen YetterKaren Yetter
<apex:page standardController="Account" showHeader="true"
      tabStyle="account" >
   <style>
      .activeTab {background-color: #236FBD; color:white;
         background-image:none}
      .inactiveTab { background-color: lightgrey; color:black;
         background-image:none}
   </style>
   <apex:tabPanel switchType="client" selectedTab="tabdetails"
                  id="AccountTabPanel" tabClass="activeTab"
                  inactiveTabClass="inactiveTab">  
      <apex:tab label="Contact Details" name="AccDetails" id="tabdetails">
        <apex:form >
        <apex:pageBlock title="Contact Details">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Account.Primary_Contact__c}"/>
                <apex:inputField value="{!Account.Lead_Analyst__c}"/>
                <apex:inputField value="{!Account.Account_History__c}"/>
                
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
      </apex:tab>
      
      <apex:tab label="Current Service Offerings" name="AccOfferings" id="tabOfferings">
        <apex:form >
        <apex:pageBlock title="Contact Details">
            <apex:pageBlockSection columns="1">
                <apex:outputField value="{!Account.Current_Services__c}"/>
                <apex:inputField value="{!Account.Flex_Program_Description__c}"/>
                <apex:inputField value="{!Account.Attachments_to_Membership__c}"/>
                
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
      </apex:tab>
      <apex:tab label="History of Account" name="AccHistory"
                id="AccHistory">
        <apex:relatedList subject="{!account}"
                           list="Primary_Contact_Histories__r" />
        <apex:relatedList subject="{!account}"
                           list="Contract_Signers__r" />
        <apex:relatedList subject="{!account}"
                           list="opportunities" />
      </apex:tab>
        <apex:tab label="Current Tasks" name="Tasks"
                id="Tasks">
         
        <apex:relatedList subject="{!account}"
                           list="OpenActivities" />
      </apex:tab>
      <apex:tab label="Who Pays For Relationship" name="PayRel"
                id="PayRel">
           <p  style="font-size: 15px;"><b>Who are on the invoices?</b> (list of everyone who received an invoice)</p>
         <apex:relatedList subject="{!account}"
                           list="Invoice_Party_Histories__r" />
         <p  style="font-size: 15px;"><b>Who is behind the budget(s)?
</b></p>
         <apex:relatedList subject="{!account}"
                           list="Behind_Budgets__r" />  
          <p  style="font-size: 15px;"><b>Who are backups for each budget holder?
</b></p>
         <apex:relatedList subject="{!account}"
                           list="Budget_Holder_Backups__r" />                    
      </apex:tab>
            <apex:tab label="Key Stakeholders / Influencer" name="Stakeholders"
                id="Stakeholders">
         <p  style="font-size: 15px;"><b>Who is currently aware of the services?</b></p>
         <apex:relatedList subject="{!account}"
                           list="AwareUsers__r" />
           <p  style="font-size: 15px;"><b>Who is not currently a user but who needs to see value?</b></p>
         <apex:relatedList subject="{!account}"
                           list="nonuser_values__r" /> 
          <p  style="font-size: 15px;"><b>Who are targets that we are working with in this relationship?</b></p>
         <apex:relatedList subject="{!account}"
                           list="Account_Targets__r" />                                   
      </apex:tab>
          
            <apex:tab label="Value of Relationship" name="Value"
                id="Value">
         <apex:form >
        <apex:pageBlock title="Contact Details">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Account.Format_of_Value_Delivery__c}"/>
                <apex:inputField value="{!Account.Meeting_Cadence__c}"/>
                <apex:inputField value="{!Account.Requests_made_by_the_client__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
      </apex:tab>
      <apex:tab label="Company Background" name="CompanyBackground"
                id="CompanyBackground">
        <apex:form >
        <apex:pageBlock title="Contact Details">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Account.Company_Description__c}"/>
                <apex:outputField value="{!Account.Current_Annual_Report__c}"/>
                <apex:outputField value="{!Account.Investor_Presentation__c}"/>
                <apex:outputField value="{!Account.Company_Overview__c}"/>
                <apex:outputField value="{!Account.Product_Overview__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
      </apex:tab>
      <apex:tab label="Engaged?" name="Engaged"
                id="Engaged">
        <apex:form >         
       <apex:pageBlock title="Are we engaged in:">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!Account.Annual_Strategic_Planning__c}"/>
                <apex:inputField value="{!Account.Annual_Conference__c}"/>
                <apex:inputField value="{!Account.PR_Communications_Team__c}"/>
                <apex:inputField value="{!Account.Any_Board_Committees__c}"/>
                <apex:inputField value="{!Account.Board_Level_Activity__c}"/>
                <apex:inputField value="{!Account.Publications_Strategy_Pieces__c}"/>
                <apex:inputField value="{!Account.Survey_Based_Marketplace_Insights_Busi__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock> 
      </apex:form>  
      </apex:tab>
        <apex:tab label="Have We Contacted...?" name="Contacted"
                id="Contacted">
        
      </apex:tab>
   </apex:tabPanel>
</apex:page>
VaasuVaasu
Try setting target property for command link
<apex:commandButton action="{!save}" value="Save" target='_Top'/>
Karen YetterKaren Yetter
When I do that I get: 
Error: Unsupported attribute target in <apex:commandButton>
VaasuVaasu
Use double quotes
<apex:commandButton action="{!save}" value="Save" target="_Top"/>
Karen YetterKaren Yetter
Thank you but I get the same message with double quotes.
Error: Unsupported attribute target in <apex:commandButton>
I wonder if it has anything to do with me being on Professional Edition.
VaasuVaasu
My bad, I just realized you are using commandbutton. :)


<apex:commandButton action="{!save}" value="Save" onComplete="refreshParentWindow('{!Account.id}'); return true;" />

<script type="text/javascript">

        function refreshParentWindow(id) 
        {
                  window.top.location.href = '/' + id;
        }


    </script>

 
Karen YetterKaren Yetter
That code works but it is still bringing up the full account page in the Account Planning section.  
VaasuVaasu
Can you use commandlink instead of button? One like below, this will fix the issue but renders as link instead of button. You can use CSS to make it look like button.
<apex:commandlink action="{!save}" value="Save" target="_top"/>
This was selected as the best answer
Karen YetterKaren Yetter
That worked perfectly.  Thank you!