Created
July 27, 2011 20:43
-
-
Save jhersh/1110328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger ApplyAssignmentRules on Lead (after insert) { | |
List<User> owner = [Select u.Id From User u where Name = 'User Portal' limit 1]; | |
if( owner.isEmpty() ) | |
return; | |
List<Lead> LeadsToUpdate = new List<Lead>(); | |
For (Lead l:trigger.new) | |
if (l.OwnerId == owner.get(0).Id) | |
LeadsToUpdate.add(l); | |
if( LeadsToUpdate.isEmpty() ) | |
return; | |
Database.DMLOptions dmo = new Database.DMLOptions(); | |
dmo.assignmentRuleHeader.useDefaultRule= true; | |
For (Lead u:LeadsToUpdate) | |
u.setOptions( dmo ); | |
update LeadsToUpdate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment