You need to sign in to do that
Don't have an account?

Apex Trigger - trigger too deep problem
Hello all,
I think the reason for this issue is because I am looking to do it on both insert and update. Basically, what I need to do is have an AccountID populated into specific fields based on the Contact that is selected. Take a look at the sample below. It does work upon insert, but I get errors afterwards - I think the trigger gets caught in an infinite loop. Any help is much appreciated!
trigger AutoFill_ContactPicklists on Contact (after insert, after update) {
List<Contact> con_list = new List<Contact>();
for(Contact con : trigger.new)
{
Contact c = new Contact();
/* SOURCE */
if(con.Business_Source__c != null)
{
for(Contact c_update : [select Id,AccountId from Contact where Id =:Trigger.new[0].Id] )
{
con_list.add(new Contact(Id=Trigger.new[0].Id,Source_Account__c=c_update.AccountId));
}
}
if(con_list.size() > 0)
{
update con_list;
}
}
That seems over complex as a trigger, and referencing the [0] means it won't work in bulk...
There may be more to your logic, but this seems to work in my instance...
awesome, thanks! I will try it later today. Thanks again.
Actually that won't work. I need to pull the Account ID of the Contact I am populating in a different field. It's not the main account ID of the Contact. Any other ideas?