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
sangam vvsangam vv 

Friends I am stuck in the Visualforce Page?

I have account(parent)
 and contact and address(both are child)
i want to create account,contact,addres in one visual force page and i want to save respected data in respected objects?
How to do pleaser help me.
Dhruv Gour 14Dhruv Gour 14
HI ,

Call a controller method "savedata " from visualforce page using <apex :action> Try controller just like =

public address add{get;set;}
public contact con{get;set;}
public account acc{get;set;}

public pagereference saveData(){;;
List<sobject> sobjlist = new list<sobject>();

insert sobjlist ;

return ;

PS: There may be some syntax error .

Please ask me if any other concern

SFDC GuestSFDC Guest
Hi Sangam W,

Please use the below code for your requirement.
Here Address__c is API Name for Address object, Account__c is lookup field in Address object.
public with sharing class AccountContactAddressCtr
    public Account acc {get; set;}
    public Contact con {get; set;}
    public Address__c address {get; set;}
    Public AccountContactAddressCtr(ApexPages.StandardController stdCtr)
        acc = (Account)stdCtr.getRecord();
        con = new Contact();
        address = new Address__c();
    public PageReference customSave()
                insert acc;
                con.AccountId = acc.Id;
                upsert con;
                address.Account__c = acc.Id;
                upsert address;
                PageReference p = new PageReference('/'+acc.Id);
                return p;
        catch(Exception e)
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Details could not be saved'));
            return null;
<apex:page StandardController="Account" extensions="AccountContactAddressCtr">
    <apex:sectionHeader title="Account, Contact, and Address" subtitle="page"/>
        <apex:pageBlockSection  title="Account Information">
            <apex:inputField value="{!acc.Name}"/>
        <apex:pageBlockSection title="Contact Information">
            <apex:inputField value="{!con.LastName}"/>
        <apex:pageBlockSection title="Address Information">
            <apex:inputField value="{!address.Name}"/>

Please mark it as best answer if it resolved your problem.

Thank You,
Sohel Mohd