Getting Started with Process Builder – Part 65 (Resolve ALL_OR_NONE_OPERATION_ROLLED_BACK error)

Getting Started with Process Builder – Part 65 (Resolve ALL_OR_NONE_OPERATION_ROLLED_BACK error)

Last Updated on April 15, 2019 by Rakesh Gupta

Process Builder is a way of automating business processes. It is an upgraded version of the Workflow Rule. Whenever a user creates a process, the system automatically creates a Visual Workflow – and a Flow Trigger (which is now deprecated) – to call the Flow. Creation of the Flow happens behind the scenes; and therefore, a user does not need to interact with these ‘shadow’ (behind the scenes) Flows. Process Builder is a powerful tool for system administrators and developers to implement business processes without writing code. However, with great power comes great responsibility  If a user starts creating a new process for each requirement – or creating processes without understanding Salesforce limitations – then, a user may encounter many issues, either in future or, during testing/deployment phase.

In my last post Getting Started with Process Builder – Part 64 (How to fix MIXED_DML_OPERATION error), I discussed how to solve Mixed Data Manipulation Language (DML) Operation Error by using Time-dependent/Scheduled action. The Time-Dependent/Scheduled action separates DML operations, on Setup and non-Setup Objects, in the same Process, and, thereby, avoids incurring a Mixed DML operation error.

This article goes one step further; it discusses another common error   ALL_OR_NONE_OPERATION_ROLLED_BACK Error. The article shows – (1) why errors could occur; (2) how to identify errors (by using a debug log); and, finally, (3) how to solve the problem.

Business Use case

Donna Serdula is working as a System administrator at Universal Containers. They just implemented Quotation Management in Salesforce. Serdula has a requirement from her manager that, as soon as an Opportunity Stage is updated to Closed Lost then auto update related quotes status to Denied.

What is ALL_OR_NONE_OPERATION_ROLLED_BACK Error?  

Let’s say that you have created a Process on the Lead object to perform some DML operation. Now you are updating 1K records via Data Loader, which triggers the Process on the Lead object. If the Process fails on any record due to a Validation Rule/Required Fields/Apex Trigger (intervening in between if you have any), it currently causes the entire batch to roll back and you will encounter ALL_OR_NONE_OPERATION_ROLLED_BACK Error.

Below, I will show you how, if there is a validation rule defined on an object, and the validation error conditions are met, a process fails and throws a rolled_back error at a user; then, I will show you how to use Dedug Log to debug ALL_OR_NONE_OPERATION_ROLLED_BACK Error and solve the problem in three easy steps:

Before we start, assume that there is a validation rule defined on the Quote Object. It states that the Description field must be populated – or cannot be null – if the Status field, on the Quote Object, updates to DeniedAlso assume that the Description field, on one of the Quotes, was left blank.

In light of the above, first, let us update Opportunity Stage to Closed Lost. This will trigger our Process on the Opportunity Object and auto update related Quotes Status to Denied.

This, in turn, will generate an ALL_OR_NONE_OPERATION_ROLLED_BACK error because, as mentioned earlier, there is a validation rule defined on the Quote Object to make sure that, if someone updates the Status to Denied then, Quote Description field cannot be null.

It is not always easy, or apparent, as to why an error occurred.  Therefore, one of your first go-to place, when an error is encountered, should be the debug log! So, let us go there!

Next, we will use Debug Log, to identify the root cause of Process failure.

And then, finally, we will update our Process – based on the root cause failure captured from the debug log – by populating the Description field and, thereby, solve ALL_OR_NONE_OPERATION_ROLLED_BACK error.

Let us create a Process that generates an ALL_OR_NONE_OPERATION_ROLLED_BACK error

There are few possible solutions for the above business scenario, but we will use the Process Builder to solve it. Follow the  instructions below to create a Process for the above business requirement 

1. Create a validation rule on Quote object to make Description field required when Status is Denied

Validation Rule - Required Description field
Validation Rule – Required Description field

2. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder
3.
 To create a new process from scratch, click on the New Button on the Process Management page. A pop-up will appear where a user can enter the Name (Use Update quotes to denied for lost opportunity as name)API Name and Description as shown in the below screenshot

Define Process Properties
Define Process Properties

4. Click on Object node to add object and then select Opportunity object. For the entry criteria, Select when a record is created or edited, as shown in the screenshot below. Once done, click on the Save button

Evaluation Criteria
Evaluation Criteria

5. The next task is to add Process Criteria. To do this click on Add Criteria, then enter NameType of action and set filter conditions as shown in the following screenshot.

  •  [Opportunity].StageName Equals Picklist Closed Lost
  • Select checkbox Do you want to execute the actions only when specified changes are made to the record? 
Process Criteria
Process Criteria

6. The next step is to add an Immediate action to the Process, to update related Quotes to Denied. First of all, add an immediate action to update quote Status to Denied, as shown in the following screenshot 

Update Records (Immediate action) - Update quote Status to Denied
Update Records (Immediate action) – Update Quote Status to Denied

7. Once done, click on the Save button, it will redirect you to Process canvas. Finally, the Process will look like the following screenshot

Don’t forget to activate the Process by clicking on the Activate button.

It’s time to test the Process

Create an opportunity record with few quotes to it, as shown in the following screenshot

Make sure that one of the quotes does not have Description field populated. The next step is to update Opportunity Stage to Closed Lost, Boooommmm, you encounter an ALL_OR_NONE_OPERATION_ROLLED_BACK error, as shown in the following screenshot:

–> Flow fault error email which is sent to the creator of the Process that is failing, is unable to explain the reason behind the ALL_OR_NONE_OPERATION_ROLLED_BACK error. Currently, as per the process builder design if a record fails at runtime, then the entire batch will roll back. 

Since the Flow fault email is unable to explain the root cause for the roll back, to identify the root cause, we will use Debug Log.

Debug log is always the best way to identify why a Process/Apex Trigger is failing at the runtime. A debug log can record database operations, system processes, and errors that occur when executing a transaction or running unit tests.

  1. Navigate to Name | Setup | Monitor | Logs | Debug Logs
  2. Click on New, set the Traced Entity Type to User and Traced Entity Name to your guest user or user who is going to test the process. Finally, select the Debug Level, as shown in the following screenshotNew Trace Flag
  3.  Once you are done click on the Save button.

The next step is to update Opportunity Stage to Closed Lost, now open the debug log (https://automationchampion.com/wp-content/uploads/2017/04/debug-log.png). Review it carefully and notice that Description field is null for second quote record; this, caused validation rule to fail and hence Process header is set to false. 

The reason for the ALL_OR_NONE_OPERATION_ROLLED_BACK error is that, currently Process Builder is designed to work only when header allOrNone is true. In another word, Process Builder will roll back all changes unless all records are processed successfully.

To solve the same error in Apex, you use the Database class method. By using the method, you can specify whether or not to allow for partial record processing if errors are encountered. You can do so by passing an additional second Boolean parameter. If you specify false for this parameter and if a record fails, the remainder of DML operations can still succeed.

Database.update(opptList, false);

By default, this allOrNone parameter is true, which means that if at least one sObject cannot be processed, all remaining sObjects will fail to process and, an exception will be thrown for the record that causes a failure.

Resolve ALL_OR_NONE_OPERATION_ROLLED_BACK error

To fix the ALL_OR_NONE_OPERATION_ROLLED_BACK error in a Process Builder or a Flow, we have to update the Process and add the Description field to it. Perform the following instructions to solve the ALL_OR_NONE_OPERATION_ROLLED_BACK error in a Process

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder
2.
 Open Update quotes to denied for lost opportunity Process. Then, click on the Clone button on the button bar and create a Version of current process

Clone a Process
Clone a Process

–> Once a process is activated, the user cannot make any changes to it. If a user wants to make changes to a Process, then, a user has to clone a Process and save it, either as a New Version or, as a New Process.

3. The next step is to modify the Immediate Action to add the Description field to it, as shown in the following screenshot:

Modify Update Records - Immediate Action
Modify Update Records – Immediate Action

4. Once done, click on the Save button, it will redirect you to the Process canvas. Finally, the Process will look like the following screenshot:

Don’t forget to activate the Process by clicking on the Activate button.

It’s time to test the Process

Open Edge SLA opportunity that you have created few moment back. Now update the Stage to Closed Lost. Notice that, Opportunity and Quotes are updated by the Process.

Technical Editor and Proofreader: - Munira Majmundar

If you have feedback, suggestions for posts or need more information about Salesforce online training program running by me. Say hello and leave and message to me!

Leave a Reply

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