You need to sign in to do that
Don't have an account?
harsha vardhan vasa 9
Need to insert contact record for every account got created.
i need to inser contact record for every new account got created.
how can we achieve this and in how many ways we can achieve ?
please send me code snippiet also in programmatic approach.
could anyone help me on this.
how can we achieve this and in how many ways we can achieve ?
please send me code snippiet also in programmatic approach.
could anyone help me on this.
You cane write trigger for that as below
You can also use process builder refer below link for the solution.
https://success.salesforce.com/answers?id=9063A000000iUqIQAU
Please mark it as Solved if my reply was helpful. It will make it available for other as the proper solution.
Thanks and Regards
Sandhya
All Answers
You cane write trigger for that as below
You can also use process builder refer below link for the solution.
https://success.salesforce.com/answers?id=9063A000000iUqIQAU
Please mark it as Solved if my reply was helpful. It will make it available for other as the proper solution.
Thanks and Regards
Sandhya
https://automationchampion.com/2015/02/13/getting-started-with-process-builder-part-1-auto-create-a-record/
Please refer the below code for default creation of contact on account creation with the use of trigger.
// Apex Class
public class CreateDefaultAccountContact {
public static void createContact(List<Account> accountList)
{
List<Contact> contactList = new List<Contact>();
for(Account acc_iteration: accountList)
{
Contact contactObject = new Contact();
contactObject.LastName = 'Default Account Contact';
contactObject.Email = 'xyz@yahoo.com';
contactObject.Title = 'Account Contact';
contactObject.AccountId = acc_iteration.Id;
contactList.add(contactObject);
}
if(contactList.size()>0)
{
insert contactList;
}
}
}
// Trigger
trigger AccountDefaultContact on Account (after insert) {
if(Trigger.IsInsert && Trigger.IsAfter)
{
CreateDefaultAccountContact.createContact(Trigger.New);
}
}
Thank You,
Ajay Dubedi