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
SathishKumarSathishKumar 

Create Records(Account, Opportunity and Contact) from VF page

Hi guys,

I want to devlop a vf page where i can create records in Account, opportunity and Contact. Opportunity and contact records must be associated with the Account.

Thanks in advance.
Rakesh ARakesh A
Create a VF page to show Account, Opportunity and Contact forms in 3 Sections.
Create a custom sontroller and there create properties (get; set;) for all fields.
Create Accout and after create and Contact and Opportunity using Account Id, as below sample code.

Account acc = new Account();
acc.Name = AccountName;  //AccountName is property/Variable
//add remaining fields
insert acc;

Contact con = new Contact();
con.LastName = ContactName;  //ContactName is property/Variable
con.AccountId = acc.Id;
//add remaining fields
insert con;

Opportunity opp = new Opportunity ();
opp.Name = OppName;    ///OppName is property/Variable
opp.AccountId = acc.Id;
//add remaining fields
insert opp;