Use default Lead Assignment rules

  • 2
  • Idea
  • Updated 5 years ago
  • Implemented
It's not possible to have a Lead form submitted by SKUID via sites to automatically run assigment rules. To solve this I created a trigger + class that runs assignment rules if a custom checkbox (hidden from users) are set to true. Maybe this quick fix can bee of use to someone else. See the code below:

trigger ReassignLeads on Lead (after insert, after update) {
List lIds=new List();
For (lead{
if (l.IsConverted==False && l.Run_Assignment_Rules__c==true){
if (AssignLeads.assignAlreadyCalled()==FALSE){
system.debug('Assign already called? '+AssignLeads.assignAlreadyCalled());


public with sharing class AssignLeads {
static testMethod void AssignLeadTest() {
//Basic code coverage test code - improve with bulk + asserts
List TestlIds=new List();
Lead newLead = new Lead(company='Testco', LastName='TestLast', FirstName='TestFirst', Run_Assignment_Rules__c=true);

if (AssignLeads.assignAlreadyCalled()==FALSE){

public static Boolean assignAlreadyCalled=FALSE;
public static boolean assignAlreadyCalled(){
return assignAlreadyCalled;

public static void assign(List lIds){
List leads=[SELECT Id FROM Lead WHERE Id IN: lIds];
For (lead l:leads){
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
l.Run_Assignment_Rules__c = false; // reset the checkbox


Photo of Peter Baeza

Peter Baeza

  • 2,868 Points 2k badge 2x thumb

Posted 6 years ago

  • 2
Photo of Anna Wiersema

Anna Wiersema

  • 10,910 Points 10k badge 2x thumb
Thanks for sharing, Peter! This is awesome.
Photo of Zach McElrath

Zach McElrath, Employee

  • 52,276 Points 50k badge 2x thumb
This has been implemented as of Skuid 4.15.8 - it is now possible to specify, at a row level, whether or not to run default Lead/Case Assignment Rules, as well as (for Leads only) to specify a particular Assignment Rule to run (if you have multiple defined in your org).

Support for various other DMLOptions has been added as well. 

See the release notes for Skuid 4.15.8 for more details (available from the Skuid releases page).