A lot of times, you'd run into a situation where you need a unique value for each user. It can be a username, slug or anything else. The method to check that a value is unique can be extended to a variety of situations.
To explain how you can let a user set a unique username for them, I've created the structure here.
I've placed a repeating group to search and display the user's details. And on the right, I've set up an input to type a new username. Upon selecting a user on the left, his/her details will be displayed in the User Info group on the right.
When we click on button Set, I set up 2 workflows to check the validity of the new username. The username/slug details are stored in User data type for each user.
Username is unique and valid
To check if the username is unique, I do a Search for Users with constraint as Slug=Input's value. If the count is 0, it means that the username is unique and I display a username changed message.
Username is not unique and valid
If the count > 0, it means that the username/slug is taken by another user and it is not valid.
I then display an error message to the user to try a new username.
The basic principle of searching a unique value can applied to a lot more cases. I hope you've understood the working and will be able to tailor it according to your own needs.