Search Community
- Force.com Discussion Boards
- :
- Salesforce User Discussions
- :
- Best Practices Discussion
- :
- Workflow rule to run active lead assignment rules
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Workflow rule to run active lead assignment rules
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-12-2009 04:54 PM
Re: Workflow rule to run active lead assignment rules
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-12-2009 05:23 PM
No, but you can use a trigger to fire assignment rules.
In Apex you can use DMLOptions to run assignment rules upon update. From the Apex Code Developers Guide:
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
Lead l = new Lead(company='ABC', lastname='Smith');
l.setOptions(dmo);
insert l;
Instead of inserting, you'd be updating the lead though.
Re: Workflow rule to run active lead assignment rules
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-13-2009 07:44 AM
Thanks for your response John.
I'm specifically trying to get the lead assignment rules to fire everytime one particular user changes the lead status of one of his leads. I know he can go in and mark the checkbox to make this happen, but we want it to be automatic.
Any thoughts on how we could specifically make this work?
Thanks,
Ben
Re: Workflow rule to run active lead assignment rules
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-13-2009 10:40 AM
You'd use the above in a trigger. This syntax should get you pretty close:
trigger myleadtrigger on Lead (before update){ for (Integer i=0; i<trigger.new.size(), i++){ if (trigger.old[i].status!=trigger.new[i].status){ Database.DMLOptions dmo = new Database.DMLOptions(); dmo.assignmentRuleHeader.useDefaultRule= true; trigger.new[i].setOptions(dmo); } } }
Re: Workflow rule to run active lead assignment rules
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-09-2009 09:30 AM
Hi,
Here is my trigger and it does not fire: It is updating the compnay name but not firing the rules.
It does update he Company Name but DOES NOT fire the rules
trigger LeadRUnAssignRules on Lead (before update){
for (Integer i=0; i<trigger.new.size(); i++){
if (trigger.new[i].Admin_CampaignRouteToRep__C = TRUE){
trigger.new[i].Company = 'Updated From Trigger';
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
trigger.new[i].setOptions(dmo);
}
}
}
Thank You
Re: Workflow rule to run active lead assignment rules
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-18-2009 07:55 AM - last edited on 12-18-2009 07:58 AM
I'm having an identical problem.
I've created a lead assignment rule to assign a lead to a que. The rule is simple and active, there is one conditional : if lead record type = A then assign to que B.
When a user creates a lead, updates it, or a lead is received from the web I want this to run. SO I created a trigger which seems to get hit but the rules refuse to run (as I understand them):
trigger ActiveLeadAssignment on Lead (before insert, before update) {
//When a lead is updated this will force the default (active) lead assignment rules to run
//no matter who the current owner is or how it was entered into the system
for (Lead l : Trigger.new) {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
dmo.emailHeader.triggerUserEmail = true;
dmo.emailHeader.triggerOtherEmail = true;
l.setOptions(dmo);
}
}
The lead is not getting assigned to the QUE under any circumstance (web to lead, user entry, user update).
Thanks!
Matt
Re: Workflow rule to run active lead assignment rules
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-22-2009 04:04 PM
I forgot a critical line in my example:
Database.update()
Here's what the revised update example would look like:
trigger myleadtrigger on Lead (before update){
for (Integer i=0; i<trigger.new.size(), i++){
if (trigger.old[i].status!=trigger.new[i].status){
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
trigger.new[i].setOptions(dmo);
database.update(trigger.new[i]);
}
}
}
gwp - in your example, add this at the bottom of the for loop:
database.update(l);

