Allow duplicate if condition is met

Hi everyone,

I am wondering if it is possible to create a query that will look into my field "BarCode" if the record exist, then it will look if the field "DeliveryDate" is null.
If it is null, It needs to stop the user from creating a duplicate entry.
If it is not null, it must allow the user to create a duplicate entry.

Ex
BarCode / DeliveryDate
12345 / 2024-09-09
67890 / null

the user would be able to create a new entry for 12345 but not for 67890

Not sure if I am making sense :thinking:

Thank you for your help !

Hi @brocantcode, we would have to run two queries to achieve this. The first query would pull all records that match the 'BarCode' the user is trying to create an entry for. We can attach a success event handler to this query, where we iterate over the response and see if any of the results have a value of null for the 'DeliveryDate'. If we find a value of null, we just raise an error to notify the user. Otherwise, we trigger the query to create the new record.