Insert a Record to an object in salesforce
Account acc = new Account();
acc.Name = 'Test Account';
Insert acc;
syntax-
objectApiName obj = objectApiName();
obj.fieldapiName = yourValue;
Insert obj;
Example-
objectApiName= Account,Contact,Broker__c
obj= acc for account , con for contact (anything you write here )
fieldapiName= required field name and all field which value you want to insert( Set mandatory fields if required.)
Example =
Contact con=new Contact();
con.lastName='Test contact';
insert con;
if any validation are activated then you put value according to your validation else it will give you error .
how to create multiple accounts at a time ?
ReplyDelete