+ Start a Discussion

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. 
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
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() {
            PageReference pg = Page.parkbepcity;
            return pg;
       public PageReference saveandTeleworkDays() {
          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}" />
<apex:commandButton value="Next" action="{!saveandCity}" id="submit"/>

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:commandButton value="Next" action="{!saveandTeleworkDays}" id="submit"/>