I use sugar 7.6 pro and I want a custom integer field id_autoincrement in the task module which is autoincremented every time that I create a new task.
If I create a task and the last created id is 10 the new one will be 11 for example.
I find a lot of posts which explain how to do this but the most completed and good are the posts with the logic hooks solution.
...and many others.
These solutions code do:
- get the max current id in the db
- increment the max id value
- assign the incremented value to the new record id
The problem is: if two new records get at the same time the max current id (e.g. max_id=10) in the db, the two new created records will have the same id (e.g. new_id1=11 and new_id2=11).
How can I avoid this problem?