• Home
  • About Us
  • Contact Us
  • Privacy Policy
  • Special Offers
Business Intelligence Info
  • Business Intelligence
    • BI News and Info
    • Big Data
    • Mobile and Cloud
    • Self-Service BI
  • CRM
    • CRM News and Info
    • InfusionSoft
    • Microsoft Dynamics CRM
    • NetSuite
    • OnContact
    • Salesforce
    • Workbooks
  • Data Mining
    • Pentaho
    • Sisense
    • Tableau
    • TIBCO Spotfire
  • Data Warehousing
    • DWH News and Info
    • IBM DB2
    • Microsoft SQL Server
    • Oracle
    • Teradata
  • Predictive Analytics
    • FICO
    • KNIME
    • Mathematica
    • Matlab
    • Minitab
    • RapidMiner
    • Revolution
    • SAP
    • SAS/SPSS
  • Humor

The New Auto Number Feature in Dynamics 365

February 16, 2018   Microsoft Dynamics CRM
New Auto Number Features 300x225 The New Auto Number Feature in Dynamics 365

Auto numbers or unique alphanumeric strings are usually needed by CRM users to uniquely identify records in UI. We have developed plugins in the past, which would generate unique identifiers for us by using counters or random strings.

Microsoft has released an “Auto number” attribute in the 9.0 version of Dynamics 365. Adding the attribute from UI is not allowed yet, but it will be soon. Until then, we can add the attribute via API.

Let’s add one.

1. Create a console application in Visual Studio.

021518 1842 TheNewAutoN1 The New Auto Number Feature in Dynamics 365

2. Add the Dynamics 365 V9.0 dlls as references. Currently, the preview version of the dlls is available in NuGet.

https://www.nuget.org/packages/Microsoft.CrmSdk.CoreAssemblies/9.0.0.4-Preview

3. Create a connection to your organization and call the CreateAutoNumberAttribute function from the Main() function.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Configuration;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Query;

using Microsoft.Xrm.Sdk.Client;

using Microsoft.Xrm.Sdk.Messages;

using Microsoft.Xrm.Sdk.Metadata;

using System.ServiceModel.Description;

static
void Main(string[] args)

{


string orgServiceUrl = ConfigurationManager.AppSettings[“orgServiceUrl”];


string userName = ConfigurationManager.AppSettings[“username”];


string password = ConfigurationManager.AppSettings[“password”];


Uri oUri = new
Uri(orgServiceUrl);


//** Your client credentials


ClientCredentials clientCredentials = new
ClientCredentials();

clientCredentials.UserName.UserName = userName;

clientCredentials.UserName.Password = password;


//Create your Organization Service Proxy


OrganizationServiceProxy _serviceProxy = new
OrganizationServiceProxy(

oUri,


null,

clientCredentials,


null);

CreateAutoNumberAttribute(“account”, “new_accountnumber”, _serviceProxy);

}

4. Following function creates an auto number attribute of “string” type in “Account” entity.

“AutoNumberFormat” is the new property that has been added to the AttributeMetadata class to help us add the auto number attribute.

public
static
void CreateAutoNumberAttribute(string entityName, string attributename, OrganizationServiceProxy _orgServiceProxy)

{


CreateAttributeRequest newAttributeReq = new
CreateAttributeRequest

{

EntityName = entityName.ToLower(),

Attribute = new
StringAttributeMetadata

{

AutoNumberFormat = “ACC-{RANDSTRING:6}”,

LogicalName = attributename.ToLower(),

SchemaName = attributename.ToLower(),

MaxLength = 150,

RequiredLevel = new
AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),

FormatName = StringFormatName.Text,

DisplayName = new Microsoft.Xrm.Sdk.Label(“Account Number”, 1033),

Description = new Microsoft.Xrm.Sdk.Label(“Unique alphanumberic number for each account”, 1033)

}

};

_orgServiceProxy.Execute(newAttributeReq);

}

5. Time to check out the new attribute!

021518 1842 TheNewAutoN2 The New Auto Number Feature in Dynamics 365

6. Let’s create few accounts and check the auto numbers!

021518 1842 TheNewAutoN3 The New Auto Number Feature in Dynamics 365

7. 9.0 version of Dynamics 365 supports the following tokens for Auto numbers:

Static String
DATE:[format]
SEQNUM:size
RANDSTRING:6

There you have it! We’re happy to have this feature added to Dynamics 365. Be sure to check out our blog for more updates, news, and tips for Dynamics 365!

Happy Dynamics 365’ing!

Let’s block ads! (Why?)

PowerObjects- Bringing Focus to Dynamics CRM

Auto, Dynamics, feature, Number
  • Recent Posts

    • Ba’al comes to CPAC, Ted Cruz jokes about his Cancun trip
    • Optimizing data migration/integration with Power Platform
    • AI Weekly: Biden calls for $37 billion to address chip shortage
    • NOT WHAT THEY MEANT BY “BUILDING ON THE BACKS OF….”
    • Why Healthcare Needs New Data and Analytics Solutions Before the Next Pandemic
  • Categories

  • Archives

    • February 2021
    • January 2021
    • December 2020
    • November 2020
    • October 2020
    • September 2020
    • August 2020
    • July 2020
    • June 2020
    • May 2020
    • April 2020
    • March 2020
    • February 2020
    • January 2020
    • December 2019
    • November 2019
    • October 2019
    • September 2019
    • August 2019
    • July 2019
    • June 2019
    • May 2019
    • April 2019
    • March 2019
    • February 2019
    • January 2019
    • December 2018
    • November 2018
    • October 2018
    • September 2018
    • August 2018
    • July 2018
    • June 2018
    • May 2018
    • April 2018
    • March 2018
    • February 2018
    • January 2018
    • December 2017
    • November 2017
    • October 2017
    • September 2017
    • August 2017
    • July 2017
    • June 2017
    • May 2017
    • April 2017
    • March 2017
    • February 2017
    • January 2017
    • December 2016
    • November 2016
    • October 2016
    • September 2016
    • August 2016
    • July 2016
    • June 2016
    • May 2016
    • April 2016
    • March 2016
    • February 2016
    • January 2016
    • December 2015
    • November 2015
    • October 2015
    • September 2015
    • August 2015
    • July 2015
    • June 2015
    • May 2015
    • April 2015
    • March 2015
    • February 2015
    • January 2015
    • December 2014
    • November 2014
© 2021 Business Intelligence Info
Power BI Training | G Com Solutions Limited