Skip to content

Instantly share code, notes, and snippets.

@theWill
Last active March 17, 2016 17:39
Show Gist options
  • Save theWill/590f827322fc9e704b04 to your computer and use it in GitHub Desktop.
Save theWill/590f827322fc9e704b04 to your computer and use it in GitHub Desktop.
public class AssignLeadsUsingAssignmentRules
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
List<Lead> Leads = [select id from lead where lead.id in :LeadIds];
for(Lead ld: Leads){
Leads.setOptions(dmo);
}
if(Leads.size() > 0)
{
update Leads;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment