Use In and Not In Operators in Flows to Find Related Records – Winter ’23

So finally the good news! You can now use the IN and NOT IN filter in a flow without customisations.

With Winter’23, Salesforce has introduced the ability to filter records without using the Loop element. This certainly saves a lot on using multiple SOQL queries and DML statements. I lived around with my customisation to solve this issue but now I am all set to get rid of that and incorporate this.

To explain flow newbies on what is going on here, look at the below SOQL query where we extract contacts related to a list of AccountIds. There was no way of filtering records without a loop or using a custom apex action inside the flow. But now there is. 🙂

Set<Id> accountIds = new Set<Id>(); 
for (Account account : [SELECT Id, Name, CreatedDate FROM Account WHERE CreatedDate = TODAY]) {
    accountIds.add(account.Id);  
} 

List contactsList = [SELECT Id, AccountId, LastName, MailingCity FROM Contact WHERE AccountId IN :accountIds AND MailingCity ='Munich'];

For reference, I am adding a screenshot of the last element.

In case you are interested how I lived with a workaround before this, please go here.

One comment

  1. […] Winter’23, Salesforce has brought this feature into the flows. Please read my blog to know […]

Leave a Reply

%d bloggers like this: