Re: How can I reassign leads based on autoassignment rules?

Danielle_Wong
Level 8 - Community Advisor

How can I reassign leads based on autoassignment rules?

My marketo is integrated with SFDC. SFDC has the autoassignment rules set up and applies it to new leads.

We made an exception for a certain campaign where leads that fill out Form A with Lead Tracking Code ABC123 will be assigned to Georgia. However, if this lead comes back and fills out Form B I want to reassign this lead based on our usual auto-assignment rules.

How can I do this? I currently have this set up like the below but it's not changing the lead owner.. it's still Georgia. Thanks in advance for your help!

pastedImage_1.png

8 REPLIES 8
Jackie_Potts
Level 7 - Champion Alumni

Re: How can I reassign leads based on autoassignment rules?

The auto assignment rules are the SFDC assignment rules from what I understand, so you would have to change the rules in SFDC to look for that form fill activity and have it reassign.

Anonymous
Not applicable

Re: How can I reassign leads based on autoassignment rules?

We are trying to solve a similar issue but from a different angle. We currently use the SFDC Lead Assignment Rules. To get the leads to run through the rules multiple times we use the Assign using active assignment rules checkbox. When that field is set to true, the lead runs through the assignment rules when there is any edit to the lead. These are settings in SF. This might begin to solve Danielle's issue. However, read on to see how this process affects assigning to an individual user.

We are trying to implement a situation where we can assign an individual as the owner or assign to a queue depending on the situation. For example, Scenario 1: A lead coming in from a Contact Us runs through the rules and gets assigned to a queue; Scenario 2: Marketing is creating a campaign that targets a customer and wants all leads to be assigned to the user who is the account owner. What we see with our current set up: The lead gets the user as the owner, but the assignment rules change it to a queue it qualifies for. We don't want to create a SF assignment rule for the account manager scenario as this is short term and the SF IT cycle of design, build, test, deploy hampers us in being efficient and flexible getting a campaign up and running. Our first Lead Assignment Rule in SF states "If lead is in a Sales Accepted status meaning the Sales owner is now the owner and not the queue, then keep the same owner. The SF Admin has suggested we put the lead in the lead status of Sales Accepted in Marketo so it meets the criteria for that first rule. Marketing Ops is not keen on this idea as it puts the Acquisition Lifecycle steps outside of the current operational campaigns. I'm looking for any suggestions that would allow us to meet both scenarios without too much "human remembering" to be a part of the process, i.e., someone building a campaign doesn't need to remember to add this step and that step to assign to an individual other than what is intuitive in assigning an owner.

Thanks.

Veronica_Holme4
Level 10 - Champion Alumni

Re: How can I reassign leads based on autoassignment rules?

Danielle - by default SFDC lead assignment rules only run on new leads - so once the lead exists and has been assigned it won't re-run.

If you need to change the owner based on a condition, you'd need to use the Change Owner flow step in Marketo, or have some kind of Process Builder or workflow manage the change in Salesforce.

Grégoire_Miche2
Level 10

Re: How can I reassign leads based on autoassignment rules?

Hi Danielle,

Vote here:

And here is the workaround:

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 thelead:trigger.new){

        if (thelead.Trigger_Assignement_Rules__c == true) {

            system.debug('Triggerassignmentrules trigger - Processing trigger:'+thelead.lastname+'-'+thelead.id);

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

            dmo.assignmentRuleHeader.useDefaultRule = true;

            thelead.setOptions(dmo);

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

            Lead Lead2 = new Lead (id=thelead.id, Trigger_Assignement_Rules__c = false );

            Lead2.setOptions(dmo);

            leadstoUpdate.add(Lead2);

        }

    }

    if(!leadstoUpdate.isEmpty()) {

        update leadstoUpdate;

    }

}

TEXT CLASS :

@IsTest

public class TriggerAssignmentRuleTest {

  public static testMethod void UnitTest() {

    Test.StartTest();

        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;

    }  

}

-Greg

Veronica_Holme4
Level 10 - Champion Alumni

Re: How can I reassign leads based on autoassignment rules?

Thanks for sharing that Greg! Much appreciated.

Grégoire_Miche2
Level 10

Re: How can I reassign leads based on autoassignment rules?

You are welcome. No support Test it on a sandbox and make sure that it does not interfere with other lead workflows or triggers !

-Greg

Casey_Grimes
Level 10

Re: How can I reassign leads based on autoassignment rules?

While Greg's method works, I'd recommend as an alternative to look at the Process Builder Blocks​ package, which will allow you to do the same thing but allow it to be invoked by Process Builder rather than by checkbox.

Grégoire_Miche2
Level 10

Re: How can I reassign leads based on autoassignment rules?

Hi Courtney Grimes,

I could have made my method work without a checkbox. But I added it to be able to control when the LAR would fire and when they would not.

If you use a process builder, you will still need a way to control when it fires. For instance with a dedicated checkbox field

-Greg