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 ------------ trigger ReassignLeads on Lead (after insert, after update) { List lIds=new List(); For (lead l:trigger.new){ if (l.IsConverted==False && l.Run_Assignment_Rules__c==true){ lIds.add(l.Id); } } if (AssignLeads.assignAlreadyCalled()==FALSE){ system.debug('Assign already called? '+AssignLeads.assignAlreadyCalled()); AssignLeads.Assign(lIds); } } ----- Class ------- 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); test.startTest(); insert(newlead); test.stopTest(); TestlIds.add(newLead.Id); if (AssignLeads.assignAlreadyCalled()==FALSE){ AssignLeads.Assign(TestlIds); } } public static Boolean assignAlreadyCalled=FALSE; public static boolean assignAlreadyCalled(){ return assignAlreadyCalled; } @future public static void assign(List lIds){ assignAlreadyCalled=TRUE; 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.setOptions(dmo); l.Run_Assignment_Rules__c = false; // reset the checkbox } update(leads); } }
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
