Fix Issues Caused by a Null Value in a Flow
Learning Objectives
After completing this unit, you’ll be able to:
- List resources for researching solutions.
- Use resources outside of the org to fix the broken flow.
- Explain the importance of accounting for a null value.
Here We Flow Again
Sometimes the issue isn’t as straightforward as a user permission problem. The problem could be anything from faulty logic to bad input data to not accounting for when a value is left blank. As stated before, even the tiniest of problems can “break” the flow. All parts, big and small, need to do their job or the flow does not work as expected.
The Problem
As the admin, you have set up a flow to email the account owner anytime a new contact is added to an account they own. However, users now need to enter contacts that aren’t associated with an account. The flow seems to be set up correctly but the users keep receiving an error when adding a contact without an associated account. Just as you did before, look over the flow and run the debug feature to see what’s going on.
Investigate the Broken Flow
Follow these steps to get to know this broken flow.
- Depending on your browser, close the debug window or tab and return to the Flow Builder screen.
- Click back in the Flow Builder.
- Click the Alert Acct Owner of New Contact Added flow.
- Review what this flow is attempting to accomplish.
Let's dive deeper into the actions of this flow.
- Click the Manager tab in the Toolbox section.
- Click the Email_Acct_Owner action.
- Review what this action is attempting to do. It will send an email with a pre-filled body and subject. However, we want the email to be sent to the account owner of the associated account.
- Delete the contents of the Recipient Address List text box.
- Enter
record
in the Email Addresses (comma-separated) text box and select Triggering Contact. Then select Account ID, then Owner ID, and finally Email.
- Click Save As New Version then Save.
- Click Debug.
- Click Run.
- Click Expand All in the Debug Details.
And… uhhh nothing? What do you mean, “No triggering record was specified, so the flow didn't run”? This flow can't be triggered in debug because debug can't create a new contact. Without a new contact, the flow is never triggered into action. What can you do? Time to do some traditional troubleshooting. Step one, re-create the issue your users are experiencing.
Activate the flow, add a contact without an associated account, and see what happens.
- Depending on your browser, close the debug window or tab and return to the Flow Builder screen.
- Click Activate.
- From within Setup, click the App Launcher.
- Select Sales and click the Contacts tab.
- Click New.
- Enter the following:
- First Name:
Steve
- Last Name:
Rogers
- Account: [leave blank]
- Click Save.
- Review the error message.
- Copy the portion of the error message that reads “0 recipients” (you need that later). Leave the New Contact window open.
Now that you’ve seen the error message, go ahead and add an account to this new contact to see how the flow works under ideal circumstances.
- Enter
GenePoint
under Account Name.
- Select GenePoint from the picklist.
- Click Save.
You should now have two new emails in your inbox. The first one is an error email from when you tried to save the contact without associating an account. When a flow fails, Salesforce sends an email to the admin (unless otherwise designated) that includes the error message from the failure and details about each flow element that the flow interview executed.
As you can see from the flow error email, there is an issue when the flow looks for the account owner email. This makes perfect sense. The flow can’t find the account owner email because an account has not been associated with the new contact. If there’s no account, there’s no account owner email. Also, take note of the Flow error: click here to debug in Flow Builder link to see the visualization of the path the flow followed. This is especially helpful when you have a flow with a lot of branches.
The second email is the result of the successfully triggered flow. You added the new contact with an associated account. You also happen to be the account owner of the GenePoint account, so you get the email alert. Note: This org has been adjusted to ensure successful account owner email delivery. If implementing this idea in a production org (test in a sandbox org first!), it may require unselecting "Activate bounce management" (Setup > Email > Deliverability > unselect Activate bounce management) and unselecting "Enable compliance with standard email security mechanisms" (Setup > Email > Deliverability > unselect Enable compliance with standard email security mechanisms) to ensure email delivery.
The flow performed as expected and notified the account owner (you) that a new contact has been associated to an account you own. As the admin, you would probably not also be the account owner, but for training purposes this example allows you to see the flow from all perspectives.
Help Is Here
While things can seem bleak, all is not lost. Help is here. There are numerous resources beyond the debug feature to help you fix your broken flow. Roll up your sleeves and dig into some resources.
-
Flow Error Email—This important resource gives you specifics related to your flow problem and is extremely helpful as you troubleshoot. The email includes the error message from the failure, details about each flow element that the flow interview executed, and a link to the visualization of the failed flow.
-
Salesforce Help—Search knowledge articles, best practices, known issues, and more. This resource allows you to search articles as well as community posts. After reviewing the flow error email, this should be your next stop when troubleshooting a broken flow.
-
Trailblazer Community Groups—Although they’re not necessarily an immediate resource for your troubleshooting problems, these user groups are a wealth of information and knowledge. Community Group members network, learn together, exchange ideas, and troubleshoot.
-
Salesforce Developer Documentation—The source of truth for Salesforce developers. Developer documentation is still worth researching, as there are nuggets of knowledge that an admin, like yourself, can use.
Since you’ve already reviewed the flow error email, your next stop is Salesforce Help. Use the search feature to find help articles, relevant posts, or Trailhead topics.
- Navigate to help.salesforce.com.
- Enter the error message you copied from before into the search bar:
0 recipients
.
- Press Enter.
- Select the Knowledge Articles checkbox to filter for just Knowledge Articles results.
- Click the Knowledge Article entitled: Error 'Probably Limit Exceeded or 0 recipients' in a Flow with a Send Email or Email Alert Action
- Read over the knowledge article.
Null Value, No Problem
The article lists three ways to make your automation work when you get this error.
- Create a validation rule to require that the field has a value.
- Make the field required.
- Update your flow so that the email alert should only fire when the email field has a value.
The first two options are not viable solutions for your situation since they don’t allow for when users legitimately need to enter a new contact that does not have an associated account. The best option is option three, only send an email alert when the email field has a value. This means that your flow should attempt to email the account owner only when the account can be found.
- In your org, click the setup gear and select Setup.
- Enter
flows
in the Quick Find box and select Flows.
- Click Alert Acct Owner of New Contact Added.
- Click Edit next to Object: Contact.
- In the Condition Requirements picklist, select All Conditions Are Met (AND).
- Click in the Field text box and select AccountId.
- Change the Operator to Is Null.
- Click in the Value text box and select $GlobalConstant.False.
- Click Save As New Version.
- Ensure A New Version is selected.
- Leave all other options as they are.
- Click Save.
- Click Activate.
You added a condition to the contact object telling the flow to not proceed to the next step if the AccountID is null (blank) and thereby not attempting to email the account owner. Next, test to see if your fix works by entering a contact without an associated account.
- Close the Flow Builder tab or window.
- From Setup, click the App Launcher.
- Select Sales and click the Contacts tab.
- Click New.
- Enter the following:
- First Name:
Lily
- Last Name:
Mason
- Account: [leave blank]
- Click Save.
No error message! More confetti. You fixed the flawed flow. The flow does not produce an error if the account field on a new contact is blank. But if a user adds a new contact with an associated account, the account owner receives an email notification as planned. Note: If you want to make sure the flow only emails account owners that are active users, add a decision element (active vs inactive) before the email element. Learn more about the Flow Element - Decision at Salesforce Help.
You fixed all the purposefully broken flows. You debugged as a different user, used Salesforce Help to find an answer, and added a filter to an object within a flow to account for a null value. If only putting together furniture were this easy.
Resources
- Website: Salesforce Help
- Website: Trailblazer Community Groups
- Website: Salesforce Developer Documentation
- Trailhead: Build Flows with Flow Builder
- Salesforce Help: Flow Element - Decision