Create a CRM auto number in less than 10 minutes (no code)

Sometimes if you just have a very basic need for an AutoNumber on a record you may want to quickly implement your own little process that is controlled by a custom entity, 2 fields on the entity you want to add the number to and a Little workflow. Once in place you can put a basic number on any entity you would like (custom and out of the box) and also more than one number in an entity.

Lets look at creating a new contact Record where we have updated the contact entity to hold our AutoNumber.

What happens is when you create your new contact record an “on creation” workflow is triggered. 

The workflow is in 3 parts and does the following 

1. links the new contact record to the AutoNumber Contact Record

2. Pulls the value from the AutoNumber record into the Contact Record

3. The value in the Auto Number record is incremented by 1 so it is ready and waiting for next time

So sounds nice and easy doesn’t it? And did I say there was no code involved? As long as you have a security role to allow you to Create Entities and Workflows you will be good to go. Lets break it down stage by stage.

Stage 1. The Custom Entity

Firstly we need to create a Custom Entity.

1. To make life easy for me I have decided to call my custom Entity “AutoNumber” 

• You may wish to change the primary field name- I have changed to Entity and increased the field length to 200

• If you don’t assign it to a menu you will always be able to create records from Advanced Find so there is no real importance on where it goes

 2. All you need to create this is 1 additional field and I am going to call it value but choose something that works for you – this should be a whole number

 3. Add that Field to the form

Stage 2. Creating the Fields in the Contact Record

We need to prepare the Entity that we want to populate the number in so in this example I will use the contact entity

1. Create a lookup field called Contact_AutoNumber and link that to the AutoNumber Entity

 2. Create a Whole Number field called Contact#

 3. Add the 2 fields to a form

Important:

• Although it may seem to be a good idea to use a calculated field to bring in the value to the contact record this wont work in practice as the value changes each time the workflow is run

Stage 3. Create an AutoNumber Record

Before you do this you will have needed to publish your changes. You can then create a Record in AutoNumber for the contact

1. Call the Record Contact AutoNumber

2. In the value field put in the starting number which may be 1 or 100,000 it is your choice 

 Things to consider:

• If you are not wanting to start from 1 because the numbers used to be allocated elsewhere choose a ‘sensible’ gap so there aren’t any overlaps

Stage 4. Create the Workflows

Create the workflow to make everything work. The work flow isn’t too complicated so even if you are new to them you should be able to follow on.

1. Create your workflow called “Contact AutoNumber” against the contact record as a Real Time Workflow

 2. Line 1 – Update Contact Record

• Populate the Contact_AutoNumber field with the record you created in Stage 3

 3. Line 2 – Update Contact Record

• Set the Contact# field to be the value field in Contact_AutoNumber

 4. Line 3 – Update the AutoNumber Record

• Set the value field to increment by 1

 5. Your workflow is good to go and can be activated

 Important things to remember

• If the workflow is run in background it can skip numbers or create duplicates, neither of which are helpful so ensure it is real time

• If you are liable to import historical information which contains a legacy number you may want to put a condition as the first step to say that if value contains data to stop or remember to deactivate the workflow before importing

Stage 5. Let’s test it out

1. Create a new contact record

2. Then create another one

3. Have your numbers pulled through?

Hopefully you have the idea on how it works now. If you wish to create an AutoNumber in more than one entity just repeat stages 2 – 5 

Stage 6. Extras

Now it works you may want to do a little housekeeping

• Have you allowed edit of the AutoNumber entity for your users? If they can’t edit they won’t be able to increment the number as part of the workflow

 • Do you want the fields on the contact record visible and editable? It is sensible to make both read only so that you have control over the field and users can’t manually update it

 • Do you want the Contact# Field visible on your views?

 • Have you made Contact# a searchable field

 • If you also make the workflow “on demand” you can run on items previously created

Remember you can also follow us / keep up to date at…. Facebook / Linked In / Blogs or sign up for our newsletter D365 Byte Sized