Reset AutoNumber

0
Hello, I have a requirement to reset the auto-number sequence  when one of my constraints is met. I have executed an SQL query and updated the current value in the 'mendixsystem$sequence' table successfully. However, when I create an object, it still follows the old sequence instead of the new sequence. Can anyone please suggest how to achieve this task?                        
asked
1 answers
0

you could use the "SELECT setval('system$filedocument_fileid_mxseq',0)" statement (on postgres databases) as an additional action besides the smendixsystem$sequence table. 

as described in https://www.postgresql.org/docs/current/functions-sequence.html#FUNCTIONS-SEQUENCE-TABLE

 

but i strongly advice not to mess up through sql statements. Mendix could always implement new autonumber-generating logic in the future.

 

and (re)setting autonumber attributes makes it possible to create duplicate values for the attribute concerned. 

 

If you want some kind of reset-to-zero attribute in your entity, I think it's better to save the last autonumber to an offset attribute and calculate a number attribute with the autonumber-offset calculation.

 

 

 

answered