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
manu123manu123 

update same object from different VisualForce pages

I have a requirement to design VF pages so that each field in custom object is on a different page.
I have used PageReference in apex class that saves the data and navigates to next object.

Problem i am facing, is the save is creating new instance of the object instead of updating.
Please provide a way to update the same instance of the object before navigating to next page.
 
Sagar PareekSagar Pareek
Can you share your code here? In place of inserting the record you can update it or consider upsert. 
SunidharSunidhar
If you are navigating to different visualforce pages, either use same controller for all the pages else you can send the created record Id as parameter in the URL to the second page and form there you can use that ID and do update operations
manu123manu123
Here is my code

public with sharing class ADDRESSNEXT {

   public list <Objection__c> lead {get;set;}
          ApexPages.StandardController stdController;
          public ADDRESSNEXT (ApexPages.StandardController con){
              stdController = con;          
          }             
                     
   public PageReference saveandcity() {
            stdController.save();
            PageReference pg = Page.parkbepcity;
            pg.setredirect(true);
            return pg;
         }    
       public PageReference saveandTeleworkDays() {
       stdcontroller.save();
          PageReference pg = Page.ParkBepTeleworkstatus;
Return pg;
         }                              
}


First page
<apex:page showHeader="true" sidebar="true" standardController="objection__c" EXTENSIONS="ADDRESSNEXT">

<apex:form ID="Member">
<apex:outputLabel value="Primary Member" for="Primary Member"/>

<apex:inputtext required="true" label="Member" value="{!Objection__c.Primary_Member__c}" />
 <br/>             
<apex:commandButton value="Next" action="{!saveandCity}" id="submit"/>
</apex:form>           
</apex:page>

Second page
<apex:page showHeader="true" sidebar="true" standardController="Objection__c" EXTENSIONS="ADDRESSNEXT">
<apex:form ID="State">
<apex:pageBlock >
<apex:pageBlockSection >     
<apex:outputLabel value="State" for="State"/>
<apex:inputfield required="false" label="State" id="State__c" value="{!objection__c.State__c}"/><br/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:commandButton value="Next" action="{!saveandTeleworkDays}" id="submit"/>                


         </apex:form>           
</apex:page>