I have a autonumber fielde with as prefix the current year and the sequence are 4 digits starting with 0001. Next January, the prefix will change and the first autonumber of the year will be 2022-0210, but I want it to reset to 0001 so the autonumber will be 2022-0001. I've read that there is no standard solution for this. I've read something about external tools like North52 or Auto Number Manager. On the other hand I'm thinking of writing an OnLoad-script that searches if there are already existing records made in the current year and fill in a custom autonumber of reset the seed while using the script. But for this I'll need to access the Dataverse-tables from within the form(-script) and I don't know how to do this at the moment.
What method would be easiest, and how should I tackle this problem? And how can I search in dataverse-tables from within a form-script? Thank you.
Solved! Go to Solution.
Hi @mvdb,
I wouldn't go the JavaScript route for these main reasons:
The out-of-the-box auto numbering feature will not allow you reset the seed/count. You need to handle this in a custom method with sync plugins and ensure uniqueness by locking the row until the new auto number is updated and committed. High-level logic:
Here's a good article explain how to achieve this: https://us.hso.com/blog/how-to-implement-robust-auto-numbering-using-transactions-in-microsoft-dynam...
Hope this helps!
Hi @mvdb,
I have done a similar approach with other customers and really accomplished this in a different way. I utilized the auto-number fields as they are and utilized a separate field (many times the default Name field) on the table and set this value based on other fields with real-time workflows. This allows me to have that field change over time if specific values change that drive the value in the unique identifier.
The real time workflow approach will execute any time the values change or the record is created.
Hope this helps! Please mark accepted if answers your question or like if helped.
Thanks,
Drew
Hi @mvdb,
I wouldn't go the JavaScript route for these main reasons:
The out-of-the-box auto numbering feature will not allow you reset the seed/count. You need to handle this in a custom method with sync plugins and ensure uniqueness by locking the row until the new auto number is updated and committed. High-level logic:
Here's a good article explain how to achieve this: https://us.hso.com/blog/how-to-implement-robust-auto-numbering-using-transactions-in-microsoft-dynam...
Hope this helps!
Another option is to use the unbound action SetAutoNumberSeed via power automate
I can confirm, that PowerAutomate will do the work. You can set the autonumber to any value.
In my Example, next Invoice number will be INV-4001356-xxx
You could run such flow on demand or on schedule
User | Count |
---|---|
19 | |
11 | |
8 | |
5 | |
5 |
User | Count |
---|---|
31 | |
31 | |
15 | |
12 | |
7 |