The Decision Element: Salesforce Flow Builder 101

Salesforce Flows are the future of automation in the Salesforce Platform. I’ve previously spoken about what the current automation landscape looks like, and Salesforce has been transparent about the future deprecation of Workflow Rules and Process Builder. As such this is the first in a series where we talk about how to use various Salesforce Flow logical elements. The first in the series? The Decision Element.

Decisions are Flows answer to an if/else statement. Conditional branching is an extremely useful tool to have and allows a single flow to go down different paths depending on filtering criteria.

We’ll keep it simple with our example use case.

The VP of Sales at Company, Inc wants all Accounts to have a standardised rating based upon their Annual Revenue for reporting purposes moving forward. If an Account has an Annual Revenue of more than $500,000 per year their rating should be hot, between $250,000-$500,000their rating should be warm, and less than that their rating should be cold.

Company Inc is a startup and they only have a handful of accounts to work with, but what if they had hundreds (or thousands?) — automation is the right tool for the job. As the Salesforce Admin for Company Inc you know that Flows are the future so that’s what we’ll build with (just not in production — right?)

For Logic statements I find it helpful to first write them out in pseudo-code, this helps give me a blue print for what I need to do within the Flow.

Here’s the pseudo-code for our business requirements:Salesforce Flow is all about the power of clicks not code, so we know we won't actually be coding anything. By now you know that this is what the Decision Element is designed to do.

We’ll start with the finished flow and work backwards about how we got there.

From our business requirements (and pseudo-code) we know that we want this Flow to run when a record is updated on the Account object. As such we want a Record-Triggered Flow.

Flow Decision Type selection

We want the Record-Triggered Flow to start when the Annual Revenue field on the Account object is updated - so set that up.

We can use the Global Boolean Value 'true' to confirm the field has been updated.

Now that we've established what starts the Flow it is time to introduce our Decision Element.

When selecting a Decision Element you add a label, an API name, and can create a description (just like when coding this is always a good idea).

Once the Decision Element has a Label and Description we can then configure the outcomes based on our Business Case.

By selecting the $Record. variable we have chosen the account that started the Flow. We then specify the Annual Revenue field for that account and choose our operators (in this case ensuring the Account Annual Revenue is greater than $500,000).

We then select the outcomes for our two other choices in the Decision Element.

Our middle outcome captures Annual Revenue between $250,000-$500,000.

The last outcome in our Decision Element captures anything less than $250,000. We don't need to specify this outcome as this is everything else.

The Account is filtering through our Decision Element tree correctly, and as such we need to choose what happens when the account is filtered. For our purpose a simple Update Record element will function. We choose this record to update the account rating to field to the right rating, and repeat this for the other two outcomes.

With our Flow complete we should test to ensure we aren't seeing any unexpected behaviour. Flow has an inbuilt debugging tool for this purpose.Start the Debug by pressing the button on the top right of the Flow page, and ensure that "Run flow in rollback mode" is selected so that our testing doesn't update your data permanently.

Select an account and through the debugger test the Annual Revenue field with a variety of numbers to ensure they flow through each path correctly based on our Decision Element.

The Debug tool will visually show you the path taken - and you can ensure the fields are updated correctly in the Debug Details column.

Once complete activate your Flow and test with your data.

Salesforce Flow testing account page - before no $value in Annual Revenue

Salesforce Flow testing account page - After updating the Annual Revenue Field the Account Rating value has updated

Congratulations! You now know how to use Decision Elements. With your Flow working and tested you can send it safely to your production Org.

See you on the Trail.

Previous
Previous

The Screen Element: Salesforce Flow Builder 101

Next
Next

Making an Activity Tab in Salesforce with Apex and Visualforce