Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2022 Release Wave 1 PlanDynamics 365 release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.
2022 release wave 1 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
Is it possible for a field to generate a customer reference number with a prefix for the business for example. Business is PAS Consultancy and I want clients to have a "PAS123456" reference that is searchable
Do i need to get an external plugin or is the functionality possibly OOB?
Thanks in advance
There is a tool Auto Number Manager in Xrm Tool box and you can setup and it will generate reference number
Business is a field on your Entity where you want to generate customer reference number?
OOB auto number can only accept static value but in your case it should be dynamic based on Business field value. You will need to write your own plugin on Pre-operation to generate custom reference number based on the Business field value.
You can use copy below code for your plugin -
public void Execute(IServiceProvider serviceProvider)
// Obtain the execution context from the service provider.
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
// Verify that the target entity represents an account.
// If not, this plug-in was not registered correctly.
if (entity.LogicalName == "account")
// An accountnumber attribute should not already exist because
// it is system generated.
if (entity.Attributes.Contains("accountnumber") == false)
// Create a new accountnumber attribute, set its value, and add
// the attribute to the entity's attribute collection.
Random rndgen = new Random();
// Throw an error, because account numbers must be system generated.
// Throwing an InvalidPluginExecutionException will cause the error message
// to be displayed in a dialog of the Web application.
throw new InvalidPluginExecutionException("The account number can only be set by the system.");
This plugin is written for account entity but you can modify this to prefix with Business field value.
Please mark my answer verified if this is helpful!
Follow my Blog: xrmdynamicscrm.wordpress.com/
brilliant - thank you for the guidance!
interesting - ill have a look, thank you!
Another approach is to create auto number attribute in CRM with sequential 6 digit format -
Then create Real Time workflow to update the auto nuber field with Business Prefix value -
this is the one!! thanks very much for this
Business Applications communities