trigger to create an contact wherever the account is created for specific set of users(say i have a set of 5 users and whenever they try to create or update an account the contact should be created or updated accordingly)
This is a scheleton of the trigger. Add the fields you need to copy from Account into Contact, and let us know if you still have issues
trigger CreateContact on Account (After Insert, After Update)
{
List<Contact> freshContacts = new List<Contact>();
if(Trigger.isInsert || Trigger.isUpdate)
{
for(Account acc : trigger.new)
{
// For each Account create a new Contact.
Contact freshCon=new Contact();
//add the information
freshContacts.add(freshCon);
}
upsert freshContacts;
//If you need to check during the update old values you can also do
/*if(Trigger.isUpdate)
{
for(Account acc : trigger.new)
{
Account oldAcc = trigger.oldMap.get(acc.Id);
//check oldAcc values with acc one
}
}*/
}
}
This is a scheleton of the trigger. Add the fields you need to copy from Account into Contact, and let us know if you still have issues