web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Reset autonumber each ...
Power Apps
Answered

Reset autonumber each year (if possible via script that searches in dataverse)

(1) ShareShare
ReportReport
Posted on by 64

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.

I have the same question (0)
  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    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

     

  • Verified answer
    EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @mvdb,

    I wouldn't go the JavaScript route for these main reasons:

    1. you still want the auto number to be set if the records are update outside the main form
    2. you can't guarantee uniqueness of your auto number (e.g. 2 records are open at the same time might have the same number)
    3. as your table grows it wouldn't scale well as the loading time of your form will increase to look at all the records.

    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:

    1. Have a separate table/entity (i.e named AutoNumberConfig) that keeps track of the current sequence, year and a lock column/field.
    2. In the auto number plugin, 1st thing is to update the lock field (generate a new guid) in AutoNumberConfig record. This will lock the row so if another record is created at the same time will wait until this row is done.
    3. Then in you auto numbering logic, check if the current year is different from the last save year. If so reset the sequence otherwise increment the sequence.
    4. Save current record with the auto number and AutoNumberConfig row with the year and sequence.

    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-dynamics-crm/ 

    Hope this helps!

     

  • AlexG7522 Profile Picture
    4 on at

    Another option is to use the unbound action SetAutoNumberSeed via power automate

  • ChrisHH Profile Picture
    6 on at

    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

     

      Screenshot 2022-02-01 at 13.21.53.png

  • DynaTech Systems Profile Picture
    4 on at

    Unfortunately, resetting an autonumber each year is not a built-in feature in most software. However, there are several workarounds to achieve the desired functionality:

    1. Scripting:

    • Power Automate (Microsoft Dataverse): You can use Power Automate to create a flow that triggers on record creation. The flow can then check the current year and reset the autonumber seed if it's a new year. This approach requires some technical knowledge and may not scale well for large datasets.
    • Airtable: Airtable supports formulas and scripts that can be used to manipulate data. You can create a formula that combines the current year with a sequential number, effectively resetting the numbering each year.
    • JavaScript/Plugins: In some platforms like SharePoint lists, you can use JavaScript or custom plugins to achieve this functionality. This approach requires advanced coding skills and is not recommended for beginners.

    2. Separate AutoNumber Field:

    • Microsoft Dataverse: Create a separate field for the autonumber that automatically resets each year. This field can be calculated based on the current year and a sequential number.
    • Airtable: Create a separate field for the year and use a formula to combine it with a sequential number.

    3. Third-party Tools:

    • North52 AutoNumber Manager: This is a popular add-on for Microsoft Dataverse that provides advanced autonumbering features, including reset options.
    • Other platform-specific tools: Several third-party tools offer similar functionality for different platforms.

    Here are some additional factors to consider:

    • Data integrity: When implementing any workaround, ensure data integrity by avoiding duplicate numbers and maintaining consistency across records.
    • Performance: Scripting solutions may impact performance, especially with large datasets. Choose an approach that scales well for your needs.
    • Technical expertise: Some methods require coding knowledge. Choose a solution that aligns with your technical skills.

    Before implementing any solution, carefully assess your specific needs, technical resources, and platform limitations to determine the most suitable approach for resetting your autonumber each year.

     

    DynaTech Systems

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard