Custom Auto Number in Dataverse with Fiscal Year-Based Incrementing Using Plugin Code
In many scenarios, businesses require custom auto-numbering for records in Microsoft Dataverse that go beyond the default functionality provided. In this article, I’ll walk you through a solution that involves creating a custom auto-number field without using the out-of-the-box auto-numbering feature in Dataverse. Instead, we’ll use a combination of a custom entity as a counter and a plugin that triggers on the pre-create event of the target table. The Approach For this solution, we’ll create a custom table called Fiscal Year Counter . This table will manage our numbering sequence based on the fiscal year. The idea is to dynamically generate invoice numbers that reset each fiscal year, providing a high level of customization to fit your organization’s unique fiscal calendar. The Fiscal Year Counter Table Setup First, create a table named Fiscal Year Counter with the following fields: Name (String): To store the fiscal year name, such as “FY2024.” Start Date (Date Only, Time...