salesforce debug assignment rules

Salesforce is closed for new business in your area.

Run Case Assignment Rule from Apex

Case assignment rules allow you to automatically route Cases to the appropriate users or queues. A Case assignment rule consists of multiple rule entries that define the conditions and order for assigning cases. You can create multiple rules (for example, a Standard rule and a Holiday rule), but only one rule can be "active" at a time.

From a standard UI, a user can trigger assignment rules by simply checking the "Assign using active assignment rules" checkbox under the Optional section. The problem arises when your app needs to insert the Case from Apex and wants to trigger assignment rules. Using this script, a Case will be inserted but assignment rules will not be triggered as there is no such field "Assign using active assignment rules" on Case.

Running Case Assignment Rules from Apex A solution is using Database.DMLOptions. The Database.DMLOptions class can provide extra information during a transaction; for example, specifying the truncation behavior of fields or assignment rule information. For example, the script below is fetching the assignment rules of Case and then creating the DMLOptions for the "Assign using active assignment rules" checkbox.

Now when the Case is inserted using this script, the assignment rules get triggered.  

Company Logo

Cookie Consent Manager

General information, required cookies, functional cookies, advertising cookies.

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings. Privacy Statement

Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.

Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.

Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.

Cookie List

CLIMB

10 Salesforce.com Case Assignment Rules Best Practices

Salesforce.com's assignment rules are a powerful tool, but they can also be complex. Here are 10 best practices to follow when using them.

salesforce debug assignment rules

Salesforce.com is a powerful customer relationship management (CRM) platform that allows organizations to manage customer data, track customer interactions, and automate processes. One of the most important features of Salesforce.com is the ability to assign cases to the appropriate team or individual.

Case assignment rules are the key to ensuring that cases are assigned to the right people in a timely manner. In this article, we will discuss 10 best practices for creating and managing Salesforce.com case assignment rules.

1. Utilize the Assignment Rules Hierarchy

The Assignment Rules Hierarchy is a way to organize and prioritize the order in which Salesforce.com Case Assignment Rules are evaluated. This ensures that the most important rules are evaluated first, allowing for more efficient case assignment.

When creating an Assignment Rule, users can specify whether it should be evaluated before or after other rules. If multiple rules have the same priority, they will be evaluated in the order they were created. By utilizing the Assignment Rules Hierarchy, users can ensure that their most important rules are evaluated first.

Additionally, when using the Assignment Rules Hierarchy, users can create rules with different criteria and assign them different priorities. For example, if a user wants to assign cases based on product type first, then by region second, they can set up two separate rules with different priorities. This allows for more flexibility and control over how cases are assigned.

2. Use Roles and Profiles to Assign Cases

Roles and Profiles are a great way to assign Cases because they allow for granular control over who can access what. By assigning Roles and Profiles, you can ensure that only the right people have access to the right Cases. For example, if you want to make sure that only certain users can view or edit sensitive customer information, you can use Roles and Profiles to restrict access to those users.

Using Roles and Profiles also makes it easier to manage Case Assignment Rules. Instead of having to manually assign each Case to an individual user, you can set up Roles and Profiles so that all Cases assigned to a particular Role or Profile will automatically be routed to the appropriate user. This saves time and ensures that Cases are always assigned to the correct person.

Additionally, using Roles and Profiles allows you to easily add new users to your system without having to manually update Case Assignment Rules. When a new user is added to a Role or Profile, they will automatically be given access to any Cases associated with that Role or Profile. This eliminates the need to manually update Case Assignment Rules every time a new user is added.

3. Utilize Queues for Case Assignment

Queues are a great way to assign cases because they allow for multiple users to be assigned the same case. This is especially useful when dealing with high-volume customer service requests, as it allows for more efficient and effective management of those requests. Additionally, queues can be used to prioritize cases based on their urgency or importance, ensuring that the most important cases get addressed first.

To use queues for case assignment, you’ll need to create a queue in Salesforce.com and add members to it. You can then set up Case Assignment Rules to automatically assign cases to the queue. This ensures that all incoming cases are routed to the right people quickly and efficiently. It also makes it easier to track which cases have been assigned and who is responsible for them.

4. Leverage Apex Triggers for Complex Assignment Logic

Apex Triggers allow for more complex logic than the standard Case Assignment Rules, such as assigning cases to specific queues based on criteria like case type or customer location. This is especially useful when dealing with large numbers of cases and multiple assignment rules that need to be applied in a certain order. Apex Triggers also provide an easy way to customize the assignment process by allowing developers to write custom code to handle any special requirements. Additionally, Apex Triggers can be used to automate the assignment process, which eliminates manual intervention and ensures that cases are assigned quickly and accurately. Lastly, Apex Triggers can be used to integrate Salesforce.com Case Assignment Rules with other systems, such as ERP or CRM applications, making it easier to manage data across multiple platforms.

5. Create a Default Rule for Unassigned Cases

Creating a Default Rule for Unassigned Cases ensures that all cases are assigned to someone, even if they don’t meet the criteria of any other rule. This is important because it prevents cases from slipping through the cracks and being left unassigned.

To create a Default Rule for Unassigned Cases, go to Setup > Customize > Cases > Case Assignment Rules. Click “New” and enter a name for the rule. Set the order number to be higher than any other rules you have created. Then set the criteria so that it will always evaluate as true (e.g., “Case: Type equals Any”). Lastly, assign the case to an appropriate user or queue.

6. Automate Case Escalation with Workflow

Automating Case Escalation with Workflow allows for cases to be automatically escalated when they are not addressed within a certain time frame. This ensures that no case is left unresolved and customers receive timely responses.

Workflows can be set up in Salesforce.com to monitor the age of open cases, and if they exceed a specified amount of time, then an automated action will occur. This action could include sending an email notification to the assigned user or group, reassigning the case to another user or group, or creating a task for someone to follow up on the case. The workflow can also be configured to send out reminders at regular intervals until the case is resolved.

This automation helps ensure that all cases are handled promptly and efficiently, which leads to better customer service and satisfaction. Automating Case Escalation with Workflow also reduces manual effort and saves time by eliminating the need to manually check each case for resolution status.

7. Allow Users to Self-Assign Cases

Self-assignment allows users to take ownership of cases they are best suited to handle. This helps ensure that the right person is assigned to each case, which can help improve customer satisfaction and reduce resolution time. It also gives users more control over their workloads, allowing them to prioritize tasks based on their own expertise and availability.

To enable self-assignment, admins should create a rule with an assignment type of “User” and assign it to all users who need access to the case. The user will then be able to select themselves as the owner when creating or editing a case. Admins can also set up criteria for self-assignment, such as assigning cases only to users in certain roles or territories. This ensures that cases are routed to the most appropriate user while still giving users the freedom to choose.

8. Make Sure Your Rules are Well Documented

Documenting your rules helps ensure that everyone in the organization understands how cases are assigned and why. This is especially important when multiple users or teams are involved in case assignment, as it ensures that all parties understand their roles and responsibilities. Additionally, documenting your rules can help you identify any potential issues with the process before they become a problem.

When documenting your Salesforce.com Case Assignment Rules, make sure to include details such as who is responsible for assigning cases, what criteria should be used to assign cases, and which team members should be notified of new assignments. You should also document any changes made to the rules over time so that everyone is aware of the current version. Additionally, consider creating a flowchart or diagram to visually represent the process. This will make it easier for everyone to understand the rules and follow them correctly.

9. Monitor Performance of your Rules

Monitoring the performance of your rules is important because it allows you to identify any issues with the rule, such as incorrect criteria or an inefficient assignment process. This helps ensure that cases are being assigned correctly and efficiently, which can help improve customer satisfaction and reduce case resolution time.

To monitor the performance of your rules, Salesforce provides a number of tools. The Case Assignment Rules report shows how many cases were assigned by each rule over a given period of time. You can also use the Rule Performance dashboard to view the average time taken for each rule to assign a case. Additionally, the Assignment Debug Logs provide detailed information about the assignment process, including the criteria used to assign the case and the user who was assigned the case. By using these tools, you can quickly identify any issues with your rules and take corrective action if necessary.

10. Test, Test, Test!

Testing is important because it allows you to ensure that the rules are working as expected and that they are assigning cases correctly. It also helps identify any potential issues or conflicts with other rules, which can be addressed before they become a problem.

Testing should include creating test cases and running them through the assignment rules to make sure they are being assigned properly. This can be done manually by creating test cases in Salesforce and then running them through the assignment rules, or it can be automated using an automation tool such as Selenium. Automated testing is especially useful for larger organizations with complex assignment rules.

It’s also important to periodically review the assignment rules to make sure they are still valid and up-to-date. This includes checking for any changes in business requirements or processes that may require updating the rules. Additionally, if there have been any changes to the data model, such as adding new fields or objects, these should be tested to make sure the assignment rules are still functioning correctly.

10 Singular Value Decomposition (SVD) Best Practices

10 perl global variable best practices, you may also be interested in..., 10 teradata sql assistant best practices, 10 react api calls best practices, 10 angular unit testing best practices, 10 project management folder structure best practices.

asagarwal.com

Blog Posts Downloadable Resources Infographics

Order of Execution (Rules, Triggers etc.) in Salesforce & Debug Log

Salesforce has a bunch of rules that can be defined on objects and fields. For example, you can define validation rules, workflow rules, process builder, flows, assignment rules, escalation rules, auto-response rules, triggers etc.

Whether you are an administrator, consultant, developer, or architect – it is important for you to understand the order in which these rules and triggers are executed.

The following picture depicts the order of execution visually. (For finer details, please refer to the Apex Developer Guide URL mentioned under ‘ References & Useful URLs ‘ section below).

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

Now, at times things will not work as you expect it to. Your system may behave like a drunk (or at least you would think so). In such cases ‘Debug Logs’ feature in Salesforce will come to your rescue. 

Let’s say that we have configured the following on Lead object

  • There is a validation rule on the lead object that states that if the lead rating is hot, the email cannot be blank
  • Then we have configured duplicate rules in Salesforce to ensure that the lead being created does not already exist
  • Then there is a Lead assignment rule defined in Salesforce that assigns all “Hot” leads to the user “Nick Admas”.
  • Then there is a workflow rule with field update action defined that sets the Industry picklist field of Lead to “Technology” if City is San Francisco.
  • Next, there is a Process Builder with criteria if Lead Status is “Site Visit’ then a Site Visit record should be created automatically mapping values from Lead.

If you are using a combination of different features in Salesforce and running into issues where the system is not behaving the way you expect it to, the best way to diagnose and troubleshoot will be to turn the debug on (Setup -> Debug Logs), execute the transaction and then check the debug log. Based on the example given above, here is what you will see in the debug log (hover on these images to enlarge).

Debugging Order of Execution in Salesforce

Keep this sequence in mind while designing your solution and your app will behave properly.

(By the way if you are preparing for Platform Developer Certification, there are a couple of questions on the order of execution)

References & Useful URLs

  • Triggers and Order of Execution – Apex Developer Guide (15 mins) – https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
  • Blog Post – Monitoring & Auditing Tools in Salesforce

Other Related posts:

  • Validation Rules Examples in Salesforce
  • How to handle junk / spam leads in Salesforce
  • My Top 10 Salesforce Blog Posts of 2020
  • Step By Step Guide to Using Restriction Rules in Salesforce
  • Step By Step Guide To Creating Record-Triggered Flow in Salesforce

32 thoughts on “Order of Execution (Rules, Triggers etc.) in Salesforce & Debug Log”

'  data-srcset=

Hi All, Anyone can please help me that above steps are correct but are they mentioned in Salesforce release notes?. I can check the given steps on one of the knowledge article of salesforce but didn’t find anything in release notes.

'  data-srcset=

H Vishal, the order of execution is not mentioned in the release notes. You can find it in Apex Developer Guide -> Triggers and Order of Execution at URL https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

'  data-srcset=

Thanks its helpful and good explanation.

My pleasure Nezam 🙂

'  data-srcset=

This order appears to no longer be valid. Spring 20 introduced Before Save Update Flows that run prior to the before triggers. This would also mean step 10 would need to be updated in the process as flows are running at a different time.

Hi Dennis, thanks for your feedback. The order has now been updated based on the Winter ’21 release of Salesforce.

'  data-srcset=

That is a great way to memorize the sequence. thank you Agarwal!

Thanks, Tulasi.

Thanks Tulasi

'  data-srcset=

what about process builder

'  data-srcset=

Duplicate rules?

'  data-srcset=

Just Awesome 🙂

'  data-srcset=

very well explaned…..For KT

'  data-srcset=

after field update coz of WR, only BT and AT will fire but no SV, CV, AR, ARR, and WR. Correct ?

'  data-srcset=

Very well explained

It is Well Explained

'  data-srcset=

Was wondering where cross object formula’s come into play and this was an enormous help ! Awesome job.

Thanks Morvana, Glad that it helped

'  data-srcset=

If Before trigger fails then, what happen to rest of execution.Whether it will stop other execution or it will execute the remaining process?

'  data-srcset=

It Helps me alottttt…. Thanx, ashish

'  data-srcset=

Thanks a lot. Its very useful

'  data-srcset=

You left out several important points – like when the records(s) are soft written to the database and then eventually committed to the DB.

It’s critical to understand that the before triggers are b/4 the write to the database and ther after triggers are after the write to the database but before the committ.

'  data-srcset=

Thanks. Good to remember this one.

'  data-srcset=

very helpful post. Is this true though – If a validation rule throws an error (i.e. the Validation Rule is working as designed), the BeforeUpdate code will get thrown away (e.g. if our BeforeUpdate code is supposed to create new Opportunity when changing Stage).

'  data-srcset=

This helped me a lot. 🙂

Glad to know that it was helpful Eugene !

'  data-srcset=

Good article, clear explanation

'  data-srcset=

That is very well explained

Thanks Ashish !

Leave a Comment Cancel Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed .

Introducing All Access Pass

  • Stremove.com on August 2, 2020 at 9:10 am

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.

salesforce debug assignment rules

  • Dayene on August 25, 2020 at 7:01 pm

Hi! What about when I want my assignment to change when the Lead status is changed? I’ve created two criterias. First when the status is new and second when the status has other values. But when the Lead is updated and the status changes the assignment doesn´t follow this change and it does not assignment the Lead Owner correctly. Thanks.

salesforce debug assignment rules

  • Vrushabh LEngade on October 27, 2020 at 3:51 pm

Use Escalation Rules and escalate the case to another user or queue

salesforce debug assignment rules

  • subhasini on December 23, 2021 at 6:19 pm

Hi Ankush Dureja, there is a interview question on assignment and the question is : What will happen if the user becomes inactive(or user is deactivated) on whom the rule is assigned. Please reply me ASAP

Leave a Reply Cancel reply

Your email address will not be published.

Popular Posts

  • Navigation Service in LWC(Lightning Web Components) 16 comments
  • Modal/Popup Lightning Web Component(LWC) 6 comments
  • Batch Apex Example In Salesforce 17 comments
  • Wrapper Class in Apex Salesforce 20 comments
  • for:each template directives in LWC 1 comment
  • Get Record Id in Lightning Web Component 9 comments
  • Lightning Web Components(LWC)Tutorial 4 comments
  • template if:true Conditional Rendering LWC 8 comments
  • Triggers in Salesforce 5 comments
  • Lightning Web Component(LWC) Toast Messages 13 comments
  • May 2023  (1)
  • March 2023  (1)
  • January 2023  (1)
  • November 2022  (1)
  • October 2022  (1)
  • September 2022  (2)
  • August 2022  (2)
  • June 2022  (1)
  • February 2022  (1)
  • January 2022  (1)
  • September 2021  (2)
  • August 2021  (1)
  • June 2021  (2)
  • May 2021  (2)
  • April 2021  (2)
  • January 2021  (2)
  • December 2020  (1)
  • October 2020  (1)
  • September 2020  (1)
  • August 2020  (2)
  • June 2020  (2)
  • May 2020  (20)
  • April 2020  (10)
  • March 2020  (6)
  • February 2020  (6)
  • January 2020  (2)
  • December 2019  (6)
  • November 2019  (3)
  • March 2019  (1)
  • February 2019  (1)
  • January 2019  (2)
  • December 2018  (7)
  • November 2018  (4)
  • October 2018  (2)
  • June 2018  (1)
  • April 2018  (1)
  • March 2018  (1)
  • January 2018  (1)
  • December 2017  (2)
  • November 2017  (1)
  • October 2017  (2)
  • September 2017  (2)
  • August 2017  (1)
  • July 2017  (1)
  • May 2017  (2)
  • April 2017  (8)
  • October 2016  (1)
  • June 2015  (1)
  • February 2015  (1)
  • October 2014  (1)
  • August 2014  (1)
  • June 2014  (4)
  • May 2014  (1)
  • April 2014  (2)
  • March 2014  (4)
  • February 2014  (22)

Recent Posts

  • How Salesforce Einstein GPT is changing the Game for Small-Medium Enterprises
  • What are the benefits of Salesforce health cloud?
  • salesforce customer 360 overview and features
  • Difference Between Workflow Process Builder and Flow
  • Salesforce Integration Interview Questions And Answers
  • Salesforce developer interview questions
  • Salesforce Admin Interview questions
  • Salesforce Lightning Interview Questions
  • Salesforce Field Service Implementation
  • Salesforce Course Details | Eligibility, Fees, Duration

Recent Comments

  • luqmaan s on Pagination using StandardSetController with wrapper class
  • Santosh on Get Record Id in Lightning Web Component
  • Micky on custom label in visualforce page
  • Syed Wassim on salesforce order of execution
  • NoviceDev on Avoid recursive trigger in salesforce

TOTAL PAGEVIEWS

  • SFDC Share Point

Our Facebook page

https://www.facebook.com/sfdcpoint

© 2024 Salesforce Blog.

Made with by Graphene Themes .

Privacy Overview

COMMENTS

  1. Set the option 'Assign using active assignment rules' to ...

    7. Click the 'Layout Properties' button on the palette and disable the 'Show on edit page' and 'Select by default' Case Assignment Check-box and click OK, then click Save. 4. Test and confirm that when a user creates a new case/lead, the 'Assign using active assignment rules' checkbox is set to true. Save the case/lead.

  2. Salesforce Lead Assignment Rules Best Practices and Tricks

    Salesforce Lead Assignment Rules are a numbered set of distribution rules that determine which owner a Lead record should be assigned (either a specific user or to a Salesforce Queue).They are generally used at the point in time when a Lead is created (typically by Web-to-lead or an integrated marketing automation platform like Pardot, Marketo, HubSpot).

  3. What is Lead Routing, and How to Use Assignment Rules in Salesforce

    Lead routing: The process of distributing incoming leads among sales reps. Also known as lead assignment, lead routing is usually automated. A lead routing process could be as simple as making an alphabetical list of all of your sales reps and assigning each new lead to whomever is next in line. More sophisticated systems depend on a variety of ...

  4. Run Case Assignment Rule from Apex

    Run Case Assignment Rule from Apex. Case assignment rules allow you to automatically route Cases to the appropriate users or queues. A Case assignment rule consists of multiple rule entries that define the conditions and order for assigning cases. You can create multiple rules (for example, a Standard rule and a Holiday rule), but only one rule ...

  5. "Mastering the Art A Comprehensive Guide to Assignment Rules in Salesforce"

    Assignment Rules in Salesforce: Imagine this: You're a lone wolf in the Salesforce jungle, battling a relentless tide of leads and cases. Hours melt away as you manually assign each one, feeling ...

  6. 10 Salesforce.com Case Assignment Rules Best Practices

    Case assignment rules are the key to ensuring that cases are assigned to the right people in a timely manner. In this article, we will discuss 10 best practices for creating and managing Salesforce.com case assignment rules. 1. Utilize the Assignment Rules Hierarchy. The Assignment Rules Hierarchy is a way to organize and prioritize the order ...

  7. Order of Execution of Rules & Triggers in Salesforce

    Order of Execution (Rules, Triggers etc.) in Salesforce & Debug Log. Salesforce has a bunch of rules that can be defined on objects and fields. For example, you can define validation rules, workflow rules, process builder, flows, assignment rules, escalation rules, auto-response rules, triggers etc. Whether you are an administrator, consultant ...

  8. Why is my Case assignment rule not firing

    2. I have two case queues, one for New Cases (this is the default on the Support settings page) and one queue for the Unreferenced (cases with no account or contact). I wrote an assignment rule for the Unreferenced queue. ISNULL ( AccountId ) && ISNULL ( ContactId ) The Problem is that these cases are still being assigned to the New Cases queue.

  9. A Complete Guide to Workflow Rule in Salesforce

    Steps to Create a Workflow Rule: Navigate to Setup. In the Quick Find box, type "Workflow Rules.". Click on "Workflow Rules.". Click the "New Rule" button. Select the object for the ...

  10. Assignment rules in Salesforce

    Create or Setup assignment rules. From Setup, enter Assignment Rules in the Quick Find box, then select either Lead Assignment Rules or Case Assignment Rules. Choose New, and then give the rule a name. Specify whether you want this to be the active rule for leads or cases created manually and via the web and email. Then click Save.

  11. How to bypass case assignment rules in apex test?

    insert newCase; // same result as this -> Database.insert(newCase, options); But after inserting owner is group: Case tempCase = [SELECT Id, OwnerId FROM Case]; System.debug('Case owner type: ' + Id.valueOf(tempCase.OwnerId).getSobjectType()); Prints this: Issue is definitely in assignment rules, because if I disable it in setup, code works as ...