How to validate for duplicate inputs

I have a table of “Brands” and I want to validate that the brand name doesn’t already exist when inserting (or updating) a record.
I understand that I’d need a workflow for this, where I’d

  1. Run an operation to get all brands
  2. Check if the inputted brand exists in that list

I also tried by trying to get a record with the name inputted, but that failed because the workflow fails if no record is found. How should I proceed to implement this logic?
Thank you

Hi, thanks for this question - it’s an interesting one.

Unfortunately, Contains will not be able to do the job here. Contains only works with strings and objects but can’t “scan” the array of objects (which a collection is) - you’ll have to create custom JS to achieve what you need

Thanks Michael, I rethought this and ended up using a custom SQL query to run a count(*) and checking if it returns 0 or 1