Thursday, May 1, 2014

Why Salesforce assignment rule is not working ?

After involve and active in Salesforce Success Answers Community for many years, I see many user confused and question on why my assignment rule is not working?

In previous blog, I discuss on assign using active assignment rule and how to set it default in page layout.

Here a few steps to troubleshoot:

1. Check the assignment rule is Active
Only one assignment rule can be active at one time in both Case and Lead.

2. Try to create the record manually in Salesforce web user interface
Check if the record is assigned to the correct user / queue and make sure checkbox Assign using active assignment rule is selected.

To support step 2, things you can do:
- Enable History Tracking
- Add object History in page layout (Case History or Lead History)

If assignment rule is working, you should see in history related list:

And compare with if Lead owner is manually change:

Can you see the difference?

3. Assignment Rules work only for specific scenario
  • Lead Assignment Rules — Specify how leads are assigned to users or queues as they are created manually, captured from the web, or imported via the lead import wizards.
  • Case Assignment Rules — Determine how cases are assigned to users or put into queues as they are created manually, using Web-to-Case, Email-to-Case, On-Demand Email-to-Case, the Self-Service portal, the Customer Portal, Outlook, or Lotus Notes.

Using Import Wizard
Select assignment rule in Step 1, even the assignment rule is not active, you can select it and it will work.

Using Data Loader
In Settings menu, enter Assignment Rule Id into Assignment rule check box, remember not Assignment Rule Name. You can retrieve the Id from Salesforce URL when you open the assignment rule, example:

If you use other API tool that not provide Assignment Rule setting,  Lead / Case created simply will not have assignment rule kick-in.

If you are using API or APEX code, you can retrieve the Assignment Rule Id and use it when create Lead or Case, here a simple snippet:

//Fetching the assignment rules on case
AssignmentRule AR = new AssignmentRule();
AR = [SELECT Id FROM AssignmentRule WHERE SobjectType = 'Case' AND Active = True LIMIT 1];

//Creating the DMLOptions for "Assign using active assignment rules" checkbox
Database.DMLOptions dmlOpts = new Database.DMLOptions();

Case newCase = new Case(Status = 'New') ;
//Setting the DMLOption on Case instance
insert newCase ;

TIPS: Salesforce processes rules in the following order:
  1. Validation rules
  2. Assignment rules
  3. Auto-response rules
  4. Workflow rules (with immediate actions)
  5. Escalation rules