Resetting of a Number after one day is completed.

0
Hey Developers  So I was working on a Feature of token , Where I need my token to be started/Refreshed from 000 after the start of next day Eg : If my token number is 20220116335 today It should be 20220117000 , I have figured out the initial configuration just needed assistance with the last 3 digits.   Regards
asked
1 answers
0

You can do it multiple ways. 

Method 1

- When creating new object for the entity, retrieve the last created item for that day in the entity, take the sequence number from the last record, increase it and assign it to your new object

- If there are no newly created items for that day, then use 000

Method 2

- You can follow a sequencing mechanism

- You can have an entity which maintains the start number, current sequence number, step increment

- When you create the entity, you take the current sequence number, use step increment to get the next number and assign it to your token

- Update your sequence entity

- With a scheduled event which runs at every day (start of the day), you can reset your sequence table

 

Take a look at https://docs.mendix.com/refguide/xpath-query-functions to derive your own intuitive ways that suites your needs.

If you want to compare the start of day, you can use the token '[%BeginOfCurrentDayUTC%]' or '[%BeginOfCurrentDay%]'

answered