You need to sign in to do that
Don't have an account?
Syed F Raza
Assign Account ID to a contact using trigger
HI All,
I am writing a trigger where if the Contact being created is not related to an account, then we should assign this contact to a particular account:
The account id I have mentioned is of an account to which I would like to assign all contacts to in case if the Account is not selected for such contacts at time of insert.
I am writing a trigger where if the Contact being created is not related to an account, then we should assign this contact to a particular account:
trigger trigger_Contact1 on Contact (before insert) { List<contact> conlist = new List<contact>(); for(Contact con :trigger.new){ if(Accountid==null) Account.id=0015G00001dSXtWQAW; conlist.add(con); } insert conlist; }
The account id I have mentioned is of an account to which I would like to assign all contacts to in case if the Account is not selected for such contacts at time of insert.
Try Below Trigger Code
Please Mark It As Best Answer If It Helps
Thank You!