Hello Harshraj Singh,
Is it a possibility to create an entity next to your customer entity that is called something like UniqueIdentifier which has a 1-* relation ship to Customer, in this way you can put a the uniqueness validation on the string attribute of UniqueIdentifier and does it need to be unique. And you have to make the flexibility to create different version of the customer.
Hope this helps,
Good luck!
I'm a bit unclear why this uniqueness can't be solved by adding a uniqueness constraint on the entity (attribute), so on the database level. So I can't advice on that.
However there are different ways of solving this concurrency problem:
- Microflow properties: set concurrent execution disallow to true, this will prevent users from executing the microflow concurrently (not very user friendly)
- Create a pessimistic locking mechanism like this module provides: https://marketplace.mendix.com/link/component/109405
- Create a non-persistent version first and when completing the form write to the persistent entity
But I think you should revisit how you want to use and generate the CustomerID, as this is typically something the database can handle well