top of page
Writer's pictureArup Roy

Retire Workflow Rules and Process Builder - Flow in Action to migrate

šŸ’” Why there is a need to migrate in to flow !!! šŸ˜’


āœ”ļø Workflow rules (WFR) are majorly used to send email alerts and perform same-record field updates. To perform faster WFR execute repetitive manner, and its significantly reduce the system performance and more resource-hungry than a single functionality equivalent to a before-save flow trigger.

āœ”ļø In addition to the shortcomings already mentioned, both processes and WFRs depend on a highly inefficient initialization phase that drives processing time up across every save-order execution theyā€™re in.

āœ”ļø Process Builder (PB) runs on top of Flowā€™s runtime, but thereā€™s a significant difference between PBā€™s user-facing design-time model and Flowā€™s runtime metadata model. This abstraction results in a processā€™s underlying metadata resolving to a twist, less-performant, and often incomprehensible Flow definition. A twisted Flow definition is much harder to debug than a non-mangled Flow definition.

āœ”ļø In case of WFRs or PBs, when criteria werenā€™t met, operations were not performed. In those cases, we spent the system resources to trigger the automation, but we didnā€™t materially benefit from the initialization phase. Its critical in processing standpoint.


šŸ’” Get Ready for Migration ā€¦


As for existing WFRs and PBs, Salesforce is helping us on transition with the new Migration tool. Regardless of its limitations, itā€™s a great tool to start with. But before we jump into the new tool, we need to determine the strategy and approach for this migration. We already know that weā€™ll have to start this process in a sandbox and perform extensive testing of all automation weā€™ll migrate or modify.


šŸ’¦ Some steps we may follow to prepare for the migration:


āš” Review the business processes and rules that correspond to automation processes in Salesforce. Make sure there are no hiccups or dead ends in the process. Visually represent these processes properly so itā€™s easier to detect blockages and identify opportunities for improvements.


āš” Once you have your process map ready, mapped it with declarative automation in each stage of the process. Here you can get a scope to identify WFRs and processes that might be inactive, outdated, or obsolete. You can update or remove them and not include in flow transition. This mapping exercise is also useful for determining context in which the new flows will run and help a lot in implementation.


āš” Itā€™s important to take time to plan and design your automation processes, make it confirm to follow the actual business rules and avoid creating new technical liability along the way. Resist the desire to fire up Flow Builder before creating a new flow to have the holistic view of the automation on the object. Try to represent the new flow in any design diagram before implementing it and outlining all the information you need. It will be a good option to use that information as an input at the time of implementation of new flow.


šŸ’” Design the solution:


When you decide to prepare the solution, keep it mind there can be some sub flow / or more than one flow will help you to build entire solution. You can consider the following in designing a automation solution with flow on top of WF/PB:


āš” Migration from WFRs to flows is not blindly 1:1. It would be a bad solution to create a new flow for each WFR. Overall perspective it wonā€™t be able to scale up or easily maintain or upgrade the process.

āš” Analyze existing flows to see if there are corresponding elements that you can update or incorporate new actions in an existing flow (you can refer the mapping doc here).

āš” Consider sub-flow whether the more complex automation processes can be reused

āš” Review whether thereā€™s a more optimized solution that doesnā€™t involve automation. For instance, if your WFR is just updating a field in an object after record created by copying value from the related other objectā€™s record, you can consider formula field instead of any other automation.

āš” For those WFs that canā€™t be incorporated into existing automation, review how youā€™re going to move them to Flow. With the help of Salesforce migration tool test the flow or try building a flow from scratch.

Itā€™s not an easy decision of how and where to migrate WFs and PBs, and thereā€™s no one-solution-fits-all approach.


šŸ’¦ Letā€™s consider a logic flow to decide on which automation tool to use:



šŸ’” Migrate workflow rules to Flow


Salesforce is helping us on transition in Flow with the Migrate to Flow tool. This is currently available in sandboxes and production environments. Please remember that you should test this in a sandbox first.

If the update happening through the workflow is independent from other processes, that means we can replace it with an independent flow, and we can utilize this tool for quick migration. But


The migration tool is still in Beta phase as mentioned by salesforce. After conversion, the new flow needs manual intervention and thorough testing. Currently the tool unable to update the fields based on the formula that uses time/date. This also doesnā€™t implement time-based email trigger.


šŸ’” Migrate processes to Flow


Salesforce has not provided a tool that can help us migrate processes yet, but this is on the near-term roadmap. Similar to what we discussed in converting WFRs to Flow, you need to make a plan and decide on the end solution. With processes, we have the option to convert every process to Flow, or for ones with complex actions, we can create a new flow out of every decision point. For simple processes that have similar triggers, we can even combine two processes into one flow. Letā€™s consider that approach.


In below example, we have two processes that are happening on the Case object. The first process is making simple updates to a field on a case when the record either gets created with P1 priority or gets updated to P1 level. The second one is triggered when a caseā€™s priority is being updated to P1 and if there was a notification sent to the Exec Sponsor. As a result, it captures the email of the support agent and the email of his manager in corresponding fields.


If we visualize these two processes, we can see how these two can be combined into one flow.


Hereā€™s the visual representation of these processes:



After we combine these two processes, the final automation solution is a record-triggered before-save flow that will handle both of these changes at the same time. This means weā€™ll initialize one automation process and save system resources, while streamlining a process and making it easier to understand and debug.


If your process has scheduled actions, those can be tricky to combine with other elements because a scheduled path in the flow can only be defined on the Start element. This might be a good case for breaking a process into multiple flows, where one handles the scheduled actions and the other updates fields that might impact the scheduling. Considering that Salesforce Architects are now suggesting we donā€™t have to follow the one flow per object approach anymore, this might be a much better, more scalable solution. Instead of building one big flow and worrying about scheduling actions, we can now build multiple flows per object and control the order of execution with a shiny, new feature called trigger ordering.

In our next example, we have a process that runs on case creation and updates the related Contact recordā€™s ā€œDo not contactā€ field so the customer doesnā€™t get spammed while the initial updates are happening. The same process also updates different fields on the Opportunity, depending on the information from the newly created Case recordā€”and it has a scheduled action at the end to uncheck that ā€œDo not contactā€ field on a related Contact after 5 minutes. If we look at the actions included in this process, we can easily conclude that it would be best to separate this action into two flows: one that will update the related Contact record and has a scheduled path, and another that will update the related Opportunity.

So, we can split this process into a flow that updates the Opportunity and looks like this:



We can then create a separate flow that updates the related Contact record with the scheduled path.



This way, we have better control over the updates, and both flows are easier to troubleshoot and debug. Equally important is that these flows are now scalable with the new criteria and will simplify maintenance, meaning it will decrease the risk of creating technical debt.


šŸ’” Significance of "Sub-flows"


Subflows are a good way to handle separate business processes and make them easier to maintain and update. To make complex business process isolated, sub flow helps significantly. To build reusable automation processes, Subflow is a best option in salesforce automation, so they can be called multiple times like components when needed in the same flow or used in another flow as well. Subflows also help simplify automation of processes that are complex and involve branching logic with control flow. It might be a good idea to have one master flow that will invoke subflows for each of the processes, it also save the performance resources from unnecessary initialization.


Another good use of subflows is if thereā€™s a need for context change. We might have a master flow thatā€™s running in user context, but we need a subflow to update records or perform an operation the user doesnā€™t have access to. We can easily solve this by setting a subflow to run in system context.


šŸ’¦ There are few limitations when it comes to using Sub-flows:


āœ”ļø Theyā€™re not available in record-triggered before-save flows.

āœ”ļø Debugging can be tricky and could be manage through error screens.

āœ”ļø There can be some overhead since subflows have to be defined as standalone flows, so we have to be careful to not overdo it.


WFRs and processes have been with us for a long time, and most admins are very comfortable using them to the point that they might have not fully embraced the flow. However, Flow is the future of Salesforce automation, and with new migration tools announced, we should look into getting more familiar and comfortable with building flows.


šŸ’¦ Some best practice to deal with any potential issues in flow:


āœ”ļø Add fault paths with error handle screens or an email alert that will send a notification about an error message.

āœ”ļø Automated Testing on flow still not available, Salesforce Automation team is working on creating automated testing for flows. So build unit tests to confirm your flow is working even after updates. You can also build tests Apex.

āœ”ļø Use debug logs to understand.

āœ”ļø Donā€™t use any hard coded IDs, or common text replace hard-coded IDs with custom labels, custom settings, or custom metadata.




Ref: Salesforce Admins.

73 views1 comment

1 comentƔrio


Pradipta Sen
Pradipta Sen
02 de ago. de 2022

This is great stuff @Arup Roy

Curtir
bottom of page