How to Add Items To a Server Action Object Array List Which Are Not Already Present?

So using Server Action Object Array Lists...

Is there a way to use Add All in Array List which will only add the items which are not already in the list?

So I have a list of contacts with fields:

id
full_name
email

and I only want the Add All in Array List function to add a contact from the new array list if there is not an item in the existing list with that value for id...

I had a similar task—I created an auxiliary simple array in a variable and added the ID to it every time I added an element to the main array, and before adding a new one, I just checked .contains() in the array variable.

1 Like

contain can be tricky, for example, 120 "contains" 12.
I think the best approach is using join id, split with comma and then use not in array
Like:

1 Like