Rudy In my vast head banging experience of this its usually that a record has been created with no ID, or in the case of sequence the 4D sequence is out of sync.
My suspicions would be records in transactions or record deletions Two suggestions.. 1) Put some code in the ‘save’ part of the record that check the ID is unique before you save it. if(Record number([Table])=-3)/if it is a new record not saved yet then there should be nothing with the id on $_l_Max:=0 else $_l_Max:=1//this record end if $ID:=[table]id SET QUERY DESTINATION(Into variable;$_l_RecordCount) Repeat query([table];[table]id=$ID) if($_l_RecordCount> $_l_Max) $ID:=$ID+1 //..the id will clash end if until($_l_RecordCount<=$_l_Max) SET QUERY DESTINATION(Into current selection) [table]id:=$ID 1) add a UUID(auto increment) primary key make your existing ID not the primary/unique(no need to change relations or anything like that) and put something in to watch for duplicates and report them to you-then you can look at how they are happening without users having an issue). Rebuilding the index hides the problem because it resets the sequence number. . > On 8 Mar 2017, at 12:26, Two Way Communications via 4D_Tech > <[email protected]> wrote: > > Hi all, > > I ran into an issue while using SEQUENCE NUMBER in 4D v15.4, in a > client-server setup. > > I put the result in a field called ‘ID’, which is the primary key for that > table, and by default is unique. Auto increment is off. > The code is running in a transaction. > > Frequently, users get the error ‘Cannot save the record, DUPLICATE KEY’. > Then, I go to the structure and rebuild the index on that field (ID). > > They try again, and the record is saved without a problem. > > After a while, though, and after other users have added records to this > table, the problem re-occurs. > Rebuilding the index again fixes the problem. > > I have exported the data to a tab delimited file, truncated the table, and > imported the data. Problem is still there. > I have compacted the data file. Same problem. > > Any ideas what can be the cause? > > Kind regards, > > Rudy Mortier > Two Way Communications bvba ----------------- > > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4d.com/archives.html > Options: http://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:[email protected] > ********************************************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

