1

I have a tabbed Opportunity page using the view overrride. So I am using one Visualforce page "OnBoardTabsOpp" with tabs and each tab is using the page include method.

<apex:tab label="Sales" name="OppDetails" id="tabdetails">
   <apex:include pageName="VisualforceSalesView"/> 
</apex:tab>

On this details tab I have the Edit button redirect to a custom VF edit page. I do this with a custom Button Edit_Opportunity_1 and on the page I use:

<apex:pageBlock mode="View">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!edit}" value="Edit"/>

           <apex:commandButton action="{!URLFOR($Action.Opportunity.Edit_Opportunity_1, Id)}" id="editButton" value="Edit Opportunity"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection showHeader="true" title="Opportunity Information" columns="2">

This loads the custom VF page, which is in Edit mode, and has the following:

<apex:page standardController="Opportunity">
    <apex:sectionHeader title="{!$ObjectType.Opportunity.label} Edit" subtitle="{!Opportunity.name}"/>
    <apex:form >
    <apex:pageBlock title="{!$ObjectType.Opportunity.label} Edit" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>

etc.

When I save from here, the changes are saved but it does not return to the same record.

It returns to the "OnBoardTabsOpp" page without a record id, so it's just blank and all the included tabs pages look blank, but if I go to the record, it has saved my changes. How do I get it to return to the right url? Thanks.

1 Answer 1

2

You can use extension class and do your save operation there and redirect from there.

<---vf page changes--->

<apex:page standardController="Opportunity" extensions="opportunityExtension">
    <apex:sectionHeader title="{!$ObjectType.Opportunity.label} Edit" subtitle="{!opp.name}"/>
    <apex:form >
    <apex:pageBlock title="{!$ObjectType.Opportunity.label} Edit" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>

<---Controller Extension--->

    public class myControllerExtension {
    public Opportunity opp{get;set;}

    public myControllerExtension(ApexPages.StandardController stdController) {
         opp = (Opportunity)controller.getRecord();
    }
    public pageReference Save(){
         update opp;
         PageReference pg = new PageReference('/'+opp.Id);
         return pg;
    }
}
1
  • your welcome : )
    – Nitin
    Jan 15, 2016 at 15:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .