Tech Tip: Auto-increment Duplicate ID in 4D
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: July 22, 2025
If 4D reuses an auto-increment value and causes a "duplicate value" error, it means the internal counter is behind the actual highest ID.
Use this command to reset the counter:
SET DATABASE PARAMETER([Table]; Table sequence number; HighestID) |
Please note that the HighestID value can be obtained in multiple ways. Here are a few example:
- Open your Data window and sort the field (that the sequence number will be used) in descending order,
to visually identify the highest value - Execute the following line of code to get the highest value on a field
HighestID:=ds.Table_1.all().max("ID")
The next sequence number that 4D will generate for the table will be HighestID+1.