Salesforce Tips for migrating Process builder to flow or trigger

In this post, I am sharing the salesforce Tips for migrating the Process builder to flow or trigger or dropping the existing process builder and incorporating it into another automation (ie trigger or flow).

Requirement Overview

  • Verify if Process Builder logic can be migrated to flow or trigger as it’s going to be depreciated very soon.

Solution Approach

Initially, Process Builders cannot handle before DML It executes after a record has been created or updated. Whereas Apex triggers can handle both before and after DML operations.

Second, the Order of execution should not be neglected at any cost.

In addition, If we have a trigger and flow in an object. In that case, if the flow can be leveraged to meet the requirement, I will say just go for it. It would help you not only purge extra lines of code and from adding unit test classes too.

Proof of Concept

Create before context flow, before context trigger, and Process Builder(runs always in after context) on the same object ie AB test (consider for POC)

Try to update the name from all three of them(flow, process builder, and trigger).
You will find the below order of execution.
First Flow gets invoked and it updates the value of the name field.
The second goes into before the context trigger and name gets overridden.
Third, the process builder gets invoked and it overrides the name field.


In after context trigger, if you are updating value on the same object it will throw an error as in after context the values are read-only, there is a workaround for it but the process builder allows that directly. Refer to the images for more clarity

Salesforce Tips for migrating Process builder to flow or trigger(Trigger execution)
Salesforce Tips for migrating Process builder to flow or trigger(Process Builder)


Remember that the decision to migrate from Process Builder to triggers or flow should be based on a careful assessment of your organization’s specific requirements and a thorough understanding of the capabilities and limitations of each approach. It may also be beneficial to consult with Salesforce experts or developers who have experience with both Process Builder and Apex triggers/Flows to make an informed decision.

Hope you find this post useful! Catch you in the next content.
And thank you for being an awesome reader.
Share and grow together !!

If you have any doubts you can comment down below, I will try to reply ASAP.

Also keep visiting us, for more such content!

Adil Ansari

Md.Adil is a Senior Salesforce developer, a Computer Science graduate working on the Salesforce platform and providing customer solutions using as a Salesforce consultant/developer. He is the founder of SalesforceBitsandBytes blogging site. He shares unique real time posts on different Salesforce implementations, the source code available on this SalesforceBitsandBytes blog is fully tested in the development environment.

Leave a Reply

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