Force execution of Salesforce Lead Assignment Rules on lead update

Force execution of Salesforce Lead Assignment Rules on lead update

When synchronizing a lead to SFDC, if it's a new lead, we can choose the "-- Use Auto-Assignment Rules --" option that will fire the assignment rules in SFDC.

But when we are updating a lead, this option has no effect. The issue behind it is that we have to replace assignment rules with workflows in SFDC which makes often the project very tricky, all the more so as the workflows cannot be made as flexible as assignment rules.

And yet, in salesforce, when we one updates a lead manually he/she as the possibility to check the following box

Furthermore, SFDC API enables to manage precisely whether or not we want assignment rules to be executed on lead update through the "AssignmentRuleHeader" (Lead | SOAP API Developer's Guide | Salesforce Developers )

So this idea is to evolve the "sync lead to SFDC" flow step so that one could choose whether or not the assignment rules should be triggered on update. The option should also be available to implicit syncs that occur when a lead is added to a program which is sync'ed with an SFDC campaign. The option could also be set at instance level, but leaving flexibility would be better.

It would avoid many issues faced by customers. i.e. :

Marketo/Salesforce Assignment Headache. Advice needed.

re-run through sfdc auto assignment rules

Trigger assignment rules in SFDC to re-assign leads 


Level 4 - Champion Alumni

Can you please send me a copy? Here's my email TIA!

Level 10

Hi Michelle,

Unfortunately, the package has been erased and cannontbe retreived. I need to rebuild it and I do not have time for the moment


Level 2

Hi Grégoire Michel​, I did something similar recently using an APEX trigger and Process Builder in SFDC. I'd be interested as to how you did this. I am unsure how to send a DM though. Free free to message me and we can share ideas.

Level 10

Hi Colin,

A simple APEX trigger and a field is enough. You do not need a process builder

Unfortunately, the package with the trigger is no longer available, so I am pasting the code here:

It takes a "Trigger_Assignement_Rules__c" field on the lead object. This field will be sync'ed to Marketo. Each time you check this field in Marketo, the trigger will fire in SFDC.

trigger triggerAssignmentRules on Lead (after insert, after update) {

    system.debug('Starting triggerAssignmentRules trigger');

    List<Lead> leadstoUpdate = new List<Lead>();

    For (lead{

        if (thelead.Trigger_Assignement_Rules__c == true) {

            system.debug('triggerAssignmentRules trigger - Processing trigger:'+thelead.lastname+'-';

            Database.DMLOptions dmo = new Database.DMLOptions();

            dmo.assignmentRuleHeader.useDefaultRule = true;


            system.debug('*******Error:  ');

            Lead Lead2 = new Lead (, Trigger_Assignement_Rules__c = false );





    if(!leadstoUpdate.isEmpty()) {

        update leadstoUpdate;





public class triggerAssignmentRuleTest {

  public static testMethod void UnitTest() {


        Lead TestLead = new Lead(LastName='Test1',Industry='Automotive', Company='ACME', Status='COL-Cold Leads', Trigger_Assignement_Rules__c = True);

        insert TestLead;

        TestLead.Status='CRL-Conversation Ready Lead';

        TestLead.Trigger_Assignement_Rules__c = True;

        update TestLead;




Not applicable

This would save our Enterprise Apps team so much time not having to write SFDC code. Our business development team has to work any marketing qualified person, that includes customers so not being able to re-trigger lead assignment rules in Marketo creates a lot of manual work on our end.

Level 2

Sorry for the very delayed response! I will certainly run this through our sandbox to see how it works. I appreciate you sharing the information.

Community Manager
Status changed to: Open Ideas