In doing a daily load of leads, my customer notified that he was not able to trigger the assignment rules:
I wanted to check if we could replicate the issue and trigger the assignment rules from the Apex snippet.
Here we go ! This is trivia, but helpful.
Just create a lead meeting the assignment rule criteria:
lead l = new lead (Lastname='testlead', company='testcompany',status = 'Unqualified',
leadsource='Innovadex',recordtypeid='012d0000000Wcq0',industry='Personal Care & Cosmetics',country='USA');
Add the following to your code to trigger the assignment rule via Apex.
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
l.setOptions(dmo);
insert(l);
Hope this helps.
No comments:
Post a Comment