Comparing two lists of things in a Workflow

Hello,

I am trying to work out how compare two lists of things. In my DB I have thing called “Entity”. An Entity is a table of other things such as people, organizations, teams, etc. I would like the user to have ability to add these Entities to a unique messaging/chat group. Each group would be distinct based on its membership of Entities.

Functionally I would like the user to be able to create a messaging a group but prevent the creation of a duplicate messaging group with the same exact members.

For example if a user creates a messaging group with Entities A, B, and C they should be prevented from creating another group containing the exact Entities A, B and C. They should however be allowed to create groups (one instance only) with combinations A and B, B and C, A and C, or A, B, C D, etc.

In the example below I want check if a MessageGroupMembers_Entities exists as a unique group of entities in the db. The problem is the that the “contains” operator does not allow me to compare two lists of things and determine an exact match. I can only check if one item in the list is contained in the Members list.

image

I tried to implement a simple brute force method like the below, but was not able to get correct match if there were fewer than three things in the matched list.

I have been banging my head trying to figure a workaround. I feel like I am missing something obvious.

Any help would be greatly appreciated.

Thanks,

Naveen

Hi there, @naveenreddyla… if I understand your post correctly, give this advanced filter a shot (ignore the references to index’s because I used a custom state in the example just so I could build out the expression), and see if it produces the desired result.

I might be overthinking/complicating this one, but the filter is counting the items that are the same in both lists and seeing if that count is equal to the count of the number of items in one of the lists while also making sure the lists have the same number of items in them (regardless of whether or not the items are the same). If both of those things are true, the group that is being created is the same as an existing group, and the condition should stop the creation of the new group.

Oh, and just food for thought… you might want to consider putting the Only when condition on the workflow event (i.e., on the button click) as to opposed to having it on the create action within the event.

Hope this helps.

Best…
Mike

2 Likes

Hi Mike,

This exactly what I was looking for. Thank you for the quick reply and assistance. I really appreciate it.

I actually had the same matching logic that you used, but I could not figure out where I could deploy it. The Advanced Filter was the answer.

And absolutely on moving the Only when condition on the create action. I had put in there to avoid to simplify the explanation.

Best,

Naveen

1 Like