When I need a unique identifier, I always create an empty item in the data storage first, capture its UID and continue working with that. I won‘t have to verify whether it exists or not.