I was developing a Salesforce Flow to automate the process of sending an email to all contacts associated with the account. For that, I retrieved the record using the ‘Get Record’ element and then added a ‘Send Email’ action to send the email to the retrieved records.
But what if the get record element doesn’t find matching records? That means it will be empty; then the flow can fail or throw an error.
That’s why it’s important to check if the Get Records result is empty before using the data in later steps.
In this tutorial, we will learn how to check if get records is empty in Salesforce Flow using an example and step-by-step explanation by adding the Get Records element.
Check if Get Records Is Empty in Salesforce Flow
Below, I will create a record trigger flow to automate the process of sending an email. There, I will explain how to check if the record is empty, and if it is not empty, then the flow will send.
If the get record doesn’t find a record, then we need to end the flow so that we won’t get any error; the flow execution will not be interrupted.
Navigate to the setup, and in the Quick Find box, search for ‘Flows’ under Process Automation.
In the flows setup window, click on the button New Flow -> Start From Scratch -> select the Record Trigger Flow -> Next.
In the start element, we have to select the triggering object. In our scenario, Account is a triggering object because it is created when the user creates or updates an account record. For that, in the Configure Trigger, we need to select A record is created or updated.
Then, add a condition: the ‘Account Priority‘ Is Changed ‘True’. Then, I selected “Actions and Related Records” in the “Optimize the Flow” option.

Next, we need to retrieve all the contacts related to the account. For that, we need to add the Get Records element and enter a Label and API Name.
Then, to filter the contacts, we only want to send emails to those records related to a particular account.
For that, add a condition. Here, I set Account ID (contact lookup field) Equals Account > Account ID. According to this condition, all the contacts related to the account will be stored in this element.

Now, what if any account doesn’t have any related contacts, that means the get record element will be empty. First, we need to check that, and then if the get record contains records, we need to send an email to those contacts.
For that, we need to add a Decision element and provide the OUTCOME ORDER. Here, I provided ‘Not Empty (Get Record)‘ and ‘Empty‘. We can add multiple outcome orders as per our requirement.
Then, for each outcome order, we need to add a condition. For the Not Empty outcome here, I added the following condition:
Get Record (Label) Is Null False. That means if the record element is not empty, then this outcome will be executed.
Otherwise, the Empty outcome will be executed.

Next, under the ‘Not Empty’ outcome, we need to add a Send Email Action element to send an email after the record is created or updated.
As you add the email action element, you need to provide the Label, and the API Name will automatically populate.
Here you need to select the field values to send an email, such as sender email, subject, body, recipient address, etc.

Now we are ready to save the flow. For that, click the Save button, provide the flow Label, and the API Name will be automatically populated.
After that, always debug the flow before activating it to ensure that the working flow is correct and that there are no runtime errors.
Click the Debug button, update any record according to the flow entry conditions, and then click the Run button.

You can see the Debug Details. The Get Record element retrieved the data, and we verified it using a condition. After sending the email, the action was executed.

Also, you can see the record we selected to run the flow, which has related contacts.

In this way, we can check if the record is empty, and if it is not empty, then the flow executes the next actions.
Conclusion
I hope you have an idea of how to check if the Get Records is empty in Salesforce Flow. I have explained by taking a scenario of sending an email to the contacts related to the account.
There, we used a decision element to check whether the get record is empty or not. If not empty, then send an email to the contacts.
You may like to read:
- Fault Paths in Salesforce Flow
- Wait Element in Salesforce Flow
- Use Formulas in Salesforce Flow
- Create and Use recordId Variable in Salesforce Flow
- Salesforce Flows: Before-Save and After-Save
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.