Process Builder + Visual Workflow, The New Code Killer?

Code Killer? Okay, maybe not. The need to build customised solutions using Apex code is not going away anytime soon. However, there are more options these days for Admins, Consultants and Developers to achieve outcomes that previously were only possible by writing code.

Process Builder and Visual Workflow have been around for a few years now, and for those who have dipped their toe into the water with these tools, it quickly becomes apparent that they offer more configuration muscle than before.

Whilst our first forays into the Process Builder may have only been to extend the capabilities of the trusty old – but limited – Workflow Rules or to create a mock Survey page with some branched logic using Visual Workflow, when Process Builder and Visual Workflow join forces we have even more possibilities at our disposal. The following example is based a client’s requirement.


Recently we had a requirement from a client that involved updating the Account Owner field on an Account record based on the update of a custom text field (also on the Account record).

The client creates and manages Account records in an external system, ‘their source of truth’, which are then created/updated in Salesforce via an overnight Integration Job using middleware. The Sales Representative responsible for an Account is represented in the external system by their ‘Rep Code’ which is mapped to a corresponding field in the Account object in Salesforce. The Sales Representatives have also been setup as Salesforce Users.


  • When the Rep Code on the Account is populated or updated in Salesforce by the Integration Job, the Account Owner needs to reflect the ‘Rep Code’.
  • If the Rep Code does not correspond to a Salesforce User, then the Account ownership should change to be the User named ‘Sys Admin’.

Investigation: Given that the requirement involved updating a lookup field we knew straightaway that a standard Workflow Rule would not work. We also knew that writing some Apex code and using a Trigger would do the trick, but was there a configurable solution?

Attempt 1: Unlike Workflow Rules invoking a Field Update, Process Builder gives us the ability to update Lookup fields. Unfortunately with Process Builder, we don’t have an action to lookup and compare a value to a value on another object.


We could call Apex to perform a matching action, however this would defeat the purpose of having a truly configured solution.

Attempt 2: Although Process Builder was missing a ‘lookup and compare’ function, Visual Workflow does have this capability when using a Fast Lookup element. Therefore by leveraging this element from our Process Builder, we could update the Account Owner with the User record  based on matching Rep Codes.

Planning: Before building any further, we drafted a design in order to determine what elements were required for the solution.


The diagram above illustrates how the whole process starts with the update of the Rep Code in the Account record. This invokes the Process Builder to pass the Account Id and Rep Code into the Visual Workflow so it can use these values to find a User with the matching Rep Code. We have one decision point to then decide who to update the Account Ownership to.


Based on our process diagram we will need:

  • 1 x Custom field on the User record to represent the Rep Code
  • 1 x Process Builder to initiate process and pass the Account Id and Rep Code to the Flow
  • 1 x Visual Workflow (aka Flow)
  • 4 x Variables within the Flow
  • 2 x Fast Lookups (for the Account and the User object)
  • 1 x Decision point (to determine how the Record will be updated)
  • 2 x Record Updates (One to update the Account Ownership to the Sys Admin User and one to update the Account Ownership to the User with a matched Rep Code)

Execution: Click on this download link to see the steps used to build the Visual Workflow and Process Builder.

Does it all work? Happily, yes!

In the example below, this Account record has no Rep Code defined and our Sales Rep, Madison Rigby, has a Rep Code of 123.


Upon entering 123 in the Rep Code field on the Account…


If I enter a Rep Code that is not stored against any of our other users…


…the Account Owner is changed to the Sys Admin User record upon save.


In closing, code is not going away in a hurry and we’ve all been guilty of first thinking ‘code will fix that’ when assessing a Client’s requirement. While this a simple enough scenario that could have been covered with a few lines of APEX and a simple Trigger, we can also see that when Process Builder and Visual Workflow join forces, the same result can now be achieved using a configuration based solution that not so long ago would only have been possible using code.

Add a Comment

Your email address will not be published.