There is no need to make any plugin or any external call for auto-numbering. Auto-numbering is now possible using just one attribute.
Things to do before getting into this.
- Should have one CRM instance. (D365 30-days free trial will do)
- Create Custom Entity (No extra fields are required except the primary one which is to be default).
That's it.
Note - We are not adding any field for auto number using CRM default solution.
So, until now, you should have one Entity created with no custom field in it (only default system generated fields). Now, it is time to write some code to see this auto-numbering thing happen.
What we have to do is to create an attribute using C# Code and make that attribute to be auto-numbered. We can even have some prefix or suffix also.
Jump to Visual Studio.
Create one console app.
First, add the reference to the following three NuGet packages.


Install the following two packages.
- Install-Package Microsoft.CrmSdk.CoreAssemblies -Version 9.0.0.5
- Install-Package Microsoft.CrmSdk.XrmTooling.CoreAssembly -Version 9.0.0.5
Add reference to System.configuration.dll.

Now, let us build and check if every package is installed properly. Add the following code to connect to CRM instance using C#.
- static void Main(string[] args)
- {
- CrmServiceClient crmServiceClientObj = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CrmOnlineStringFromAppConfig"].ConnectionString);
- if (!crmServiceClientObj.IsReady) Console.WriteLine("No Connection was Made.");
- Console.WriteLine("Connected");
- }
To know more about connecting C# to CRM Online Instance, check out my blog Simple Code to connect to MS D365 Online using console Application.
Run the application to test if it is connected. You need to create two objects -
- StringAttributeMetadata to set attribute meta data
- CreateAttributeRequest which will hold entity name and attribute.




Join the conversation! Your thoughts help the community grow.