Use In and Not In Operators in Salesforce Flow : Bijay Kumar
by: Bijay Kumar
blow post content copied from SalesForce FAQs
click here to view original post
### Summary of Salesforce Flow Operators In Salesforce Flow, the **Get Record** element is used to retrieve records from various objects. When you store these records as a collection, you have the option to filter records using the **In** and **Not In** operators. This allows you to effectively manage and operate on your data without writing complex queries. #### Key Points: 1. **In and Not In Operators**: - **In Operator**: Allows you to filter records to include only those in a specified collection. - **Not In Operator**: Used to filter out records from a collection, allowing you to exclude specific values. 2. **Use Cases**: - **Example 1 (In Operator)**: Automating email reminders for contract renewals for accounts with specific subscription types (e.g., Diamond, Platinum). The flow checks daily for contracts expiring in 30 days and sends notifications only to eligible accounts. - **Example 2 (Not In Operator)**: Automatically deleting leads older than one year while excluding those from priority sources (like Outbound Calls and Partner Referral). The flow identifies and deletes these leads while notifying the lead owners. 3. **Step-by-Step Implementation**: - Create a scheduled flow and retrieve records using the Get Records element. - Filter records based on specified criteria. - Use Loop elements to iterate through records and Assignment elements to store IDs in variables. - Utilize Decision elements to determine which records to delete or notify. 4. **Practical Applications**: - These operators streamline workflows and help manage data efficiently, ensuring compliance with Salesforce's governor limits. ### Conclusion Understanding how to use the **In** and **Not In** operators in Salesforce Flow is crucial for automating processes effectively. This knowledge can significantly improve data handling in various business scenarios. ### Additional Resources - Explore how to create and use the **recordId** variable in Salesforce Flow. - Learn about using the **Loop** element in Salesforce Flow. - Discover how to call the **Approval Process** from Salesforce Flow. ### SEO Hashtags #Salesforce #SalesforceFlow #InOperator #NotInOperator #ProcessAutomation #SalesforceTips #SalesforceDevelopment #DataManagement #FlowAutomation #CRM This summary provides a clear understanding of the In and Not In operators in Salesforce Flow, along with practical examples, making it easier for users to leverage these functionalities in their workflows.
In Salesforce Flow, we use the Get Record element to retrieve records from an object. When we store those records as a collection, there will be two options for the records: either we want to use records from that collection, or we do not want the records to be from that collection.
For this, we have the In and Not In operators in Salesforce Flow, which we can use to perform operations on the records in the collection variable.
In this article, I will explain how to use “In” and “Not In” operators in Salesforce Flow. In this, we will learn where it can be used and how to use it, with real-time examples and step-by-step explanations.
What are In and Not In Operators in Salesforce Flow?
Using the ‘In’ and ‘Not In’ operators in Salesforce Flow, we can easily query the related data without writing a query inside the loop element. Use the In operator to ensure that your flows do not exceed governor limits.
The new operators allow you to access collections of the following types: Text, Number, Date, Date/Time, Currency, and Boolean. The operators can be found in the elements “Get Records”, “Update Records”, and “Delete Records”.
Example 1: Use the In Operator in Salesforce Flow
Below, I will explain the use case and demonstrate how to use the In operator in Salesforce Flow to access records from a list (collection variable).
A sales company wanted to automate the process of sending automated renewal contract reminder emails 30 days before the contract expiration to their account holders. However, only those with a subscription type of either Diamond or Platinum are eligible.
To send a reminder email 30 days before contract expiration, we need to check daily if any contracts will expire. For this, we will use the Schedule Trigger Flow.
- 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. Select the option Schedule-Triggered Flow, and click Create.
- Select the Start Date and Start Time to schedule the flow. After this, select the frequency from the options: Once, Daily, and Weekly.
Next, we need to retrieve all the accounts stored in the Account object. For that, we need to add the Get Records element and enter a Label and API Name.
Then, to filter the account records, add a condition. Here, I set the Subscription Type equal to ‘Diamond’ or ‘Platinum’.
Due to these filter conditions, we retrieved only those records that met the defined criteria. Then we need to store ‘All Records‘ as a collection.

Now we want to store all the IDs of retrieved accounts in a variable. For that, we need to iterate over all account records and retrieve the account ID.
We will use the loop element to iterate over the records retrieved in the ‘Get Record’ element. To add the Loop Element, click on the Add Element icon.
Then, enter the element Label and API Name.
Then, select the Collection Variable from Get Records(API Name) and select the iteration direction from the first item to the last item.

To store the Account IDs, we need to create a new variable. To do that, click New Resource and select the Resource Type as Variable. Enter API Name. Here, I have entered DiamondPlatinumPlanIds.
Select ‘Data Type’ as ‘Text‘ and allow multiple values, and click on Done.

In this step, we will add the ‘Account ID’ from the current record of the loop element. To do so, add the Assignment Element. Then, enter the element Label and API Name.
Here in the Set variable Values, I added a condition as follows:
DiamondPlatinumPlanIds -> Add -> Loop > Account ID: Here, we store the account ID in the created collection variable.

Next, we need to retrieve all the contracts whose contract end date is in the next 30 days, stored in the Contract object. For that, we need to add the Get Records element and enter a Label and API Name.
Now we will filter the conditions so that we can retrieve only those records that meet the defined criteria.
Here, I added two conditions as follows:
- Contract End Date -> Equals ->TODAY()+30 (Formula Resource).
- Account ID ->IN -> DiamondPlatinumPlanIds (Text Variable).
Here, we also need to select the All Records option to store all account IDs and contract end date records in the collection.

Again, add the Loop element and select the above get record element API Name, where we have stored all contract and account IDs.

Now, again, we need to add the Assignment element where we store the accounts because we want to send an email to an account.
This ensures that we receive only accounts related to contracts with upcoming renewals within 30 days and those with Diamond or Platinum plans.

After that, we would like to send an email to the accounts to notify them that their contract will expire in 30 days. For that, add the Send Email action.
Here you need to select the field values to send an email, such as sender email, subject, body, recipient address, etc.
In the body, we inform the account holder that their contract will expire in 30 days. Whatever you want to send as an email template, you can send.

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. Then activate the flow.


Proof of Concept:
Below, you can see that I received an email with the contract number and expiration date. These emails will now only be sent to accounts with a subscription type of Diamond or Platinum, and their contracts will expire within the next 30 days.

In this way, we can use the In operator in Salesforce Flow to access records from a list.
Example 2: Use Not In Operator in Salesforce Flow
Now, I will explain how to use the ‘Not In’ operator in Salesforce Flow with picklist values to check if a value is not included in a list of values. (collection variable).
A company wanted to automatically delete Leads if they were older than 1 year, but to skip Leads that came from priority sources, such as ‘Outbound Calls’ and ‘Partner Referral.’
To delete leads that are older than 1 year, we need to check the created date so we can schedule a trigger flow.
Set the start element according to your requirements.
Next, add a Get Record element to retrieve the leads that are older than 1 year. For that, I added the following condition:
- Created Date > Less Than > TODAY() – 365 (Formula Resource).
After that, we also only want those leads whose sources are ‘Outbound Calls’ and ‘Partner Referral.’
After adding the conditions, we need to select the “Store All Records” option so that it will function as a collection variable (list).

Then, create a new resource type as ‘Variable‘ with a data type of ‘Record‘ and select the ‘Lead‘ object, allowing multiple values to store the lead IDs.

Now, add the Loop element and select the above ‘Get Record‘ element API Name, where we have stored all leads.
Now, we will add the ‘Leads IDs’ from the current record of the loop element. To do so, add the Assignment Element. Then, enter the element Label and API Name.
Here in the Set variable Values, I added a condition as follows:
PriorityLeadSourcesCollections -> Add -> Loop > Lead ID: Here, we store the lead ID in the created collection variable.

After that, add a Decision element to check whether the lead IDs we added in the record collection variable in the assignment element are available or not.

If the records are available in the collection variable, we need to delete those records. To do this, we must add a Delete Record element and provide the variable in the Record or Record Collection field.

Then, using the send email element to notify the lead owner that the record has been deleted successfully.

After that, save the flow and debug it before activating.


Proof of Concept:
Below you can see I have a record which is older than one year, and also it doesn’t have ‘Outbound Calls’ and ‘Partner Referral’ lead sources.

After executing the flow, you can see that the lead owner received an email stating that the record has been deleted.

Let’s check whether the record has been deleted. To do this, navigate to the lead object and search for the lead mentioned in the email.
You can see that before executing the query, the record was present, but now, as you search for it, the record is no longer visible, which means the record was deleted successfully.

In this way, we can utilize the “Not In” operator in Salesforce flow with picklist values to verify if a value is not included in a list of values. (collection variable).
Conclusion
I hope you have got an idea of how to use “In” and “Not In” operators in Salesforce Flow. In this, we have learned where it can be used and how to use it, with real-time examples and step-by-step explanations.
You may like to read:
- Create and Use recordId Variable in Salesforce Flow
- Use Loop Element in Salesforce Flow
- Call Approval Process From Salesforce Flow
The post Use In and Not In Operators in Salesforce Flow appeared first on SalesForce FAQs.
July 04, 2025 at 01:35PM
Click here for more details...
=============================
The original post is available in SalesForce FAQs by Bijay Kumar
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Post a Comment