+ Start a Discussion
CyberfireCyberfire 

Inactive assignment rule not firing after update?

For some reason, when using the below trigger (which was provided in part by the salesforce developer pilot program), it will not invoke the inactive assignment rule which is called out. The only way we were able to get it to work is if we specify "after insert", which completely defeats the purpose of what this trigger is supposed to do.

 

Does anyone see any holes?

 

 

trigger Updatelead1 on Lead (after update) { //First get all the updated leads List<Lead> uptdLeads = new List<Lead>(); // Check Each Lead's owner, Invoke assignement rule if the owner is "00G50000000z37R" for(Lead ul : uptdLeads ){ if(ul.OwnerId == '00G50000000z37REAQ' ){ System.debug('$$$$Owner Matched'); database.DMLOptions dmo = new database.DMLOptions(); dmo.AssignmentRuleHeader.assignmentRuleID ='01Q500000006mKtEAI'; ul.setOptions(dmo); uptdLeads.add(ul); } } if(!uptdLeads.isEmpty()) Database.update(uptdLeads)

 

 

 

JorgeLCaceresJorgeLCaceres
Assignment rules only work for new record inserts. Alternatively, you can use a workflow with a field update to change the owner.