Sunday, November 8, 2015

Salesforce Case/Lead Assignment Rules

One of the nice features of Salesforce Cases and Leads is the ability to setup Assignment Rules that will assign a record to a specific queue and send a notification when certain criteria are met. In this article I will show the basics of setting up Case Assignment Rules and how to they work with the REST API. Lead Assignment Rules work basically the same way so I will only cover Cases.

To setup the rules, go to Setup, App Setup, Customize, Cases and select Case Assignment Rules. You will see a list of any rules that are currently setup.


Click New to create a new rule and enter a unique name. At this point you can check Active to enable this rule immediately, or you can wait until you have completed the setup of the rule and activate it later.



Once you enter the name you will be taken back to the rule list where you can click on the rule to edit it.


Next to Rule Entries, click New to create a new rule entry. Here I have setup a rule that will assign the case to the US – Platinum Gold queue when the priority is High and the Reason is Breakdown. The sort order at the top is used if you have more then one rule and determines the order they are applied. Once the criteria of a rule is met none of the other rules will be evaluated. If you want the user or queue notified then be sure to select an e-mail template otherwise the e-mails will not be sent but the cases still will be re-assigned.


Once you have completed the rule entry you will be returned to the initial screen for the rule where you will want to edit the Rule Detail and select active to activate the rule.

When you use the REST API to create or update a Case all the active rules will be applied. The API also provides an HTTP header called Sforce-Auto-Assign that gives you some more control over this. If you are using the System.Net.HttpWebRequest class you would add the header like this:

request.Headers.Add(“Sforce-Auto-Assign: TRUE”);

There are three possible values for this header. Setting it to TRUE will cause all active assignment rules to be applied, which is the default behavior if you leave off the header. If you set it to FALSE, none of the rules will be applied. The final option is to use the id of an assignment rule like this:

request.Headers.Add(“Sforce-Auto-Assign: 01QE0000000bJiI”);

In this case, only that one rule will be applied, and it will be applied even if it is not active. You can get the Rule ID from the URL while you are editing the rule: