Thursday, April 21, 2022

Open Process Builder as Flow

 

We all know that Salesforce will sunset workflow and process builder (PB) in the near future, and for workflow migration to flow, there's an official tool that will be GA next release. There might be something similar coming to PB eventually but for the moment I think we still need a decent amount of effort to "rebuild" them into Flow.

I recently got a task to rebuild a quite big PB (with quite a few decisions). Since it's saved as Flow in the metadata, I wondered if it's possible to edit it as a Flow. After some experiments, I figured out a hack to do this.

First, run a SOQL using Tooling API, in order to get the PB's Id.

SOQL:

SELECT  VersionNumber,  Definition.DeveloperName, Status,  id from flow where Definition.DeveloperName = 'Process_Name'

Then you can see a list of all the versions of that PB with corresponding Ids. Grab the one you want to rebuild (usually the latest version or active version), which looks like

'301xxxxxxxxxxxxxxx'

Finally, click any Flow in your Flow list to open its editor, and you'll see an url like

https://yourdomain.lightning.force.com/builder_platform_interaction/flowBuilder.app?flowId=301xxxxxxxxxxxxxxx

Simply replace the Id, and voila, the PB is opened in flow builder.

The layout may be ugly and messy when you open it, but you can easily get a good-looking version by changing the UI from Freedom to Auto-Layout.

Freedom



Auto-Layout



But it's not perfect yet, we still have a bunch of work to make it a record-triggered flow, starting with Save As button on the top right corner.


You will see an error immediately because Salesforce doesn't know what object it is.



It's easy to fix by selecting the same object of PB in the Start element.


You also need to change the trigger to match the original PB.

The next thing is to add an element to assign the record to the myVariable of PB after the Start element.



Depending on the elements in PB, you may still see some warning messages on the top right corner telling you some formula does not work, which requires your attention. Maybe some other performance issues, but you should be able to activate the Flow now.



Until now you have a quick and dirty Flow of the old PB. This should give you a better starting point for the rebuilding process. To properly migrate the PB, it's better to look through the logic and refactor it into Flow, and that's why I say this is a hack that should be only used with your own discretion.







No comments:

Post a Comment

Tips for Salesforce Certified Strategy Designer Exam

A little late to the party, but I just passed the latest Strategy Designer exam. Since it's a really new one (about one week old), there...