You need to sign in to do that
Don't have an account?
Christopher_J
Visual Workflow creates lead by lead assignment rule isn't observed.
Has anyone run into this issue? I'm creating a lead with a Visual Flow form but the lead assignment rule doesn't assign it to Salesperson.
Help!
Chris
Help!
Chris
You could use the AssignmentRuleHeader in an Apex trigger, as in this post:
http://salesforce.stackexchange.com/questions/13651/lead-assignment-rule-in-a-trigger
I assume you'll only want to reassign leads that came from your website, so you'll need a way to check that in your trigger. Assuming these leads have a source of "website", and drawing off of the example above, you could write something like
trigger LeadTrigger on Lead (after insert) {
List<Lead> ls = new List<Lead>();
for (Lead l : Trigger.new) {
if (l.LeadSource = 'Website') {
ls.add(new Lead(id = l.id));
}
}
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
Database.update(ls, dmo);
}
If you're able to modify the code that is sending the leads from your site to Salesforce, you could set the AssignmentRuleHeader from that end as well.
Or,
To enforce Assignment Rules in Apex you'll need to instantiate the Database.DMLOptions class, set the useDefaultRule property of assignmentRuleHeader to True, and finally call a native method on your Lead called setOptions, with the Database.DMLOptions instance as the argument. The code below demonstrates:
// to turn the Assignment Rules on
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
theLead.setOptions(dmo);
http://www.soliantconsulting.com/blog/2009/11/setting-lead-assignment-rules-with-apex
Regards,
Ashish