+ Start a Discussion

Creating records across multiple objects



I have a VF page, Sign Up, where i intend to capture data from the user for a new sign up.


The Data is divided into 3 sections: 


Account Data: Personal Information

Service Order Data: Choice of the service plan, Order Date etc (custom fields)

Credit Card Info


There is one Save button. 


On clicking the Save button on the Sign Up VF page, i want a record to be automatically created in 2 tabs viz. Accounts(standard object) and Service Order (custom object).


I could create a record for the Accounts tab(standard object) using the follwing apex controller:


public class SignUp {

Account account ;

public Account getAccount()
   if(account == null)
     account = new Account();
  return account;
public PageReference save()
  // Add the account to the database.  
      insert account; 
      return null;




Now i want to create a record for the custom object Service Order (for the Order related and Credit Card data) referencing the Account record just created. So i want the flow to be Save -> Account -> Service Order


On 1 click i want records to be created at multiple places.


What are the ways to do it? Is it possible to do it from the above controller ?


Please Help !!