Custom maxId reset after 200
Hello,
i've set my records to automatically assign a custom record number +1 at each new record using the formula:
let t := this;
let maxId := max((select 'Storage Clients').'ID Pratica n.');
t.('ID Pratica n.' := maxId + 1)
I would need to know how i can set the maxId to rest after 200 records.
Thanks for ythe help!
8 replies
-
or even reset at the end of the day would be a solution
-
One option could be to build the needed serial number by using the record reference number, the numeric part of the automatically created record identifier. I mean something like:
let n := number(Id) - 1;
'ID Pratica n.' := 1 + n - floor(n / 200) * 200
-
thanks Alain for the reply.
i've set my inital formula in the TRIGGER ON CREATE section. Where should i set the formula you suggested?
not very handy with coding.... i would need to understand exactly how and where i should write this
Thanks!
-
It should work in the same place, Trigger on create. Another possibility would be to make "ID Pratica n." a formula field, defined as:
let n := number(Id) - 1;
1 + n - floor(n / 200) * 200
-
LOOKS GREAT. THE ONLY PROBLEM IS THAT LINKING IT TO number(Id) if i delete the record because of errors during the filling procedure it jumps to the following record therfore i lose 1 record number
-
it acts with the same logic of Ninox Id Number..
-
Solutions based on the Ninox Id are robust, since it is guaranteed to be unique and never reused. But if you delete a record, its number is of course lost forever, per the non-reuse.
A less robust solution, but without missing numbers, would be to put this as the "Trigger on create" function definition:
let n := last((select Table1).'ID Pratica n.');
'ID Pratica n.' := 1 + n - floor(n / 200) * 200
It uses the "last" function instead of "max" but, since the records found by the "select" command are ordered by Id by default, it should work pretty reliably.
-
thanks Alain! I will give it a try
Content aside
- 4 yrs agoLast active
- 8Replies
- 621Views