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
Kumar5Kumar5 

Tabpanel Upsert Method

Hello All,

I am creating Visual force page with tabpanel having two tabs contacts and opportunites. I want to  upsert the records using the id with first tab details.

Please help me with upsert method 

<apex:page Controller="panelController" showHeader="true">
<apex:form >
    <!-- Define Tab panel .css styles -->
    <style>
    .activeTab {background-color: #236FBD; color:blue; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
            
    <!-- Create Tab panel -->
    <apex:tabPanel switchType="client" selectedTab="name2" id="ContactTabPanel"
        tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="One" name="name1" id="tabOne">
         <apex:pageBlock title="ContactDetails"> 
         <apex:inputField value="{!confields.name}"/>
         <apex:inputField value="{!confields.phone}"/>
         <apex:inputField value="{!confields.type}"/>
       
       <apex:inputField value="{!confields.phone}"/>
         <apex:inputField value="{!confields.email}"/>
        </apex:pageblock>
         <apex:commandButton value="save" action="{!saveRecord}"/>
        </apex:tab>
        <apex:tab label="Two" name="name2" id="tabTwo">
        
         <apex:pageBlock title="OpportunityDetails"> 
         <apex:inputField value="{!oppfields.name}"/>
         <apex:inputField value="{!oppfields.status}"/>
         <apex:inputField value="{!oppfields.date}"/>
       

        
        <apex:pageBlock title="contactdetails">
       <apex:inputField value="{!confields.citizenship__c}"/>
         <apex:inputField value="{!confields.alliance__c}"/>
        </apex:pageblock>
         <apex:commandButton value="save" action="{!saveRecord1}"/>
        </apex:tab>
        
         </apex:tab>
    </apex:tabPanel>
  </apex:form>
</apex:page>


Controllerpublic with sharing class panelController {

public Account accfields{get;set;}
public contact confields{get;set;}

public panelController(){
accfields=new Account();
confields=new Contact();
}
public PageReference saveRecord() {
    insert accfields;
    insert confields;
        return null;
    }
    
    Public PageReference SaveRecord1()
    {}
}

Thanks,
Kumar