Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.
Geschätzte Zeit

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.

  1. Depending on your browser, close the debug window or tab and return to the Flow Builder screen.
  2. Click back Flow Builder back button in the Flow Builder.
  3. Click the Alert Acct Owner of New Contact Added flow.
  4. Review what this flow is attempting to accomplish.

Let's dive deeper into the actions of this flow.

  1. Click the Manager tab in the Toolbox section.
  2. Click the Email_Acct_Owner action.
  3. 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.
  4. Delete the contents of the Recipient Address List text box.
  5. Enter record in the Email Addresses (comma-separated) text box and select Triggering Contact. Then select Account ID, then Owner ID, and finally Email.
  6. Click Save As New Version then Save.
  7. Click Debug.
  8. Click Run.
  9. 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.

  1. Depending on your browser, close the debug window or tab and return to the Flow Builder screen.
  2. Click Activate.
  3. From within Setup, click the App Launcher.
  4. Select Sales and click the Contacts tab.
  5. Click New.
  6. Enter the following: 
    • First Name: Steve
    • Last Name: Rogers
    • Account: [leave blank]
  1. Click Save.
  2. Review the error message.
    New Contact error message: We can’t save this record because the “Alert Acct Owner of New Contact Added” process failed. Give your Salesforce admin these details. 0 recipients
  3. 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.

  1. Enter GenePoint under Account Name.
  2. Select GenePoint from the picklist.
  3. 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.

Email sent by flow when new contact was created

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. 

  1. Navigate to help.salesforce.com.
  2. Enter the error message you copied from before into the search bar: 0 recipients.
  3. Press Enter.
  4. Select the Knowledge Articles checkbox to filter for just Knowledge Articles results.
  5. Click the Knowledge Article entitled: Error 'Probably Limit Exceeded or 0 recipients' in a Flow with a Send Email or Email Alert Action
  6. 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. 

  1. In your org, click the setup gear Setup gear and select Setup.
  2. Enter flows in the Quick Find box and select Flows.
  3. Click Alert Acct Owner of New Contact Added.
  4. Click Edit next to Object: Contact.

The Start element on the Flow Builder canvas

  1. In the Condition Requirements picklist, select All Conditions Are Met (AND).
  2. Click in the Field text box and select AccountId.
  3. Change the Operator to Is Null.
  4. Click in the Value text box and select $GlobalConstant.False.Condition Requirements added to the Contact object.
  5. Click Save As New Version.
  6. Ensure A New Version is selected.
  7. Leave all other options as they are.
  8. Click Save.
  9. 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.

  1. Close the Flow Builder tab or window.
  2. From Setup, click the App Launcher.
  3. Select Sales and click the Contacts tab.
  4. Click New.
  5. Enter the following: 
    • First Name: Lily
    • Last Name: Mason 
    • Account: [leave blank]
  1. 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

Teilen Sie Ihr Trailhead-Feedback über die Salesforce-Hilfe.

Wir würden uns sehr freuen, von Ihren Erfahrungen mit Trailhead zu hören: Sie können jetzt jederzeit über die Salesforce-Hilfe auf das neue Feedback-Formular zugreifen.

Weitere Infos Weiter zu "Feedback teilen"