In and Not In Operators in Flows

Salesforce's Winter'23 release included this much-needed feature ↠ In and Not In operators in flow builder. With In and Not in operators, we can easily query the related data without writing a query inside the loop element.

Salesforce’s Winter’23 release included this much-needed feature ↠ In and Not In operators in flow builder.

With In and Not in operators, 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.

Note: the In and Not In operators don’t support accessing values on record collections in this release.

Advertisements

Use case of “In” operator

Check whether the currently logged-in user has CREATE/EDIT permission on the Opportunity object.

ObjectPermissions: Represents the enabled object permissions for the parent PermissionSet.

In the SOQL query, To obtain the object permission for the user, we must write the query shown below.

SELECT PermissionsEdit, PermissionsCreate
FROM ObjectPermissions
WHERE ParentId <strong>in </strong>(SELECT PermissionSetId FROM PermissionSetAssignment WHERE
AssigneeId ='005B0000008b9dVIAQ') AND SobjectType='Opportunity'

Let us now translate this SOQL query into our flow solution.

❶ Use the Get Records element to get the PermissionSetAssignment records.

❷ Add the Loop element and select the “Get_Permissionset_assignment” collection variable.

❸ Create a collection variable resource called PermissionSetIDs to store the PermissionSetID

❹ Put the Permission Set IDs in this variable from the loop element.

Inside the loop element click on the (+) plus icon and add an Assignment element. Select the PermissionSetIDs in the variable field, select Add in the operator, and select PermissionSet ID from the loop element.

❺ Add Get Records element outside for loop and get the Object Permissions record.

Filter ① Used to filter the object.

Filter ② IN operator is used to filter the records based on PermissionSetID.

❻ Add a Decision element and set the condition as shown in the screenshot below.

The final flow will look like this.

Advertisements

Summary

Flow can access a collection of primitive values without using the Loop element by using the new In and Not In operators. 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. This new operator is very useful when you try to build complex logic inside flow.

I’d like to hear from you!

← Back

Thank you for your response. ✨

Please rate our website(required)

Advertisements
Advertisements
Arun Kumar
Arun Kumar

Arun Kumar is a Salesforce Certified Platform Developer I with over 7+ years of experience working on the Salesforce platform. He specializes in developing custom applications, integrations, and reports to help customers streamline their business processes. Arun is passionate about helping businesses leverage the power of Salesforce to achieve their goals.

Articles: 162

Leave a Reply

Discover more from SFDC Lessons

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from SFDC Lessons

Subscribe now to keep reading and get access to the full archive.

Continue reading