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. 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 in (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!

Advertisements
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s