Advanced CRM 2011 Auto Number supports a vast range of different Display Format. It is very flexible in a way that it doesn't restrict you on the number of prefix / postfix / delimiters and where they are located in the text.

All generated values are identified by the use of curly brackets. The current position number is defined by using {CurrentPosition}. The display format can reference other CRM fields (within the same entity or through N:1 relationship) as a part of the generated values.

Here are all the supported display formats. All examples below assuming the auto number has been configured on accountnumber attribute of account entity.

Basic Examples
  • {CurrentPosition} produces 1
  • {CurrentPosition.PadZero(5)} produces 00001
  • ACC-{CurrentPosition} produces ACC-1
  • ACC-{CurrentPosition}-XYZ produces ACC-1-XYZ
  • ACC-{CurrentPosition}-{RandomCharacters(5)} produces ACC-1-gqwer
  • ACC-{CurrentPosition}-{RandomNumbers(5)} produces ACC-1-45738 NEW
  • ACC-{CurrentPosition.PadZero(5)} produces ACC-00001
  • ACC-{CurrentPosition.PadZero(5)}-ABC produces ACC-00001-ABC
  • ACC-{CurrentPosition.PadZero(5)}-{RandomCharacters(5)} produces ACC-00001-eriqj
  • ACC-{CurrentPosition.PadZero(5)}-{RandomNumbers(5)} produces ACC-00001-32903 NEW

Advanced Examples

This examples assume that the address1_country will be populated with "Australia" as a part of the account creation.
  • ACC-{CurrentPosition.PadZero(5)}-{address1_country} produces ACC-00001-Australia
  • {address1_country.ToLower()}{CurrentPosition.PadZero(5)} produces australia00001
  • {address1_country.ToUpper()}-{CurrentPosition.PadZero(5)} produces AUSTRALIA-00001
  • {address1_country.Substring(2).ToLower()}{CurrentPosition.PadZero(5)} produces au00001
  • {address1_country.Substring(1,2).ToLower()}{CurrentPosition.PadZero(5)} produces us00001 NEW
  • {address1_country.Substring(2).ToUpper()}{CurrentPosition.PadZero(5)} produces AU00001
  • {address1_country.Substring(1,2).ToUpper()}{CurrentPosition.PadZero(5)} produces US00001 NEW
  • ACC-{CurrentPosition.PadZero(5)}-{address1_country.Substring(2).ToUpper()}-{RandomCharacters(5).ToUpper()} produces ACC-00001-AU-PQOER

The example below assumes that the primarycontactid lookup is populated with a contact named "Joe Bloggs".
  • ACC-{CurrentPosition.PadZero(5)}-{primarycontactid.fullname.Substring(3).ToUpper()} produces ACC-00001-JOE

Last edited Jun 4, 2012 at 11:17 AM by xrmbits, version 12


viktorj Mar 25, 2015 at 11:54 AM 
Hi! I've been using this solution for a while now and I really like it. I know it's probably a long shot, but I was wondering if someone could advise on the following.

I have two entities, Transport Routes and Stops with a 1:N relationship. I want to auto-number the Stops records sequentially (1, 2, 3, etc.) but want to start at 1 within each Transport Route. So Route A should have Stop 1, Stop 2, Stop 3 child records, and Route B should again have Stop 1, Stop 2, Stop 3 child records. How should go about it? Can this solution be configured so, or should I try via JavaScript, or maybe a custom Plugin?

Would appreciate any thoughts!

shirsath44 Dec 20, 2012 at 5:45 AM 
is there any setting for following sequence ?

AJonEvans Nov 12, 2012 at 12:30 PM 
Hello. This solution is exactly what I've been after for a while and fits the bill perfectly. However, as often happens, when you provide something so good, it's not long before people ask "Well, if it can do that, can it also do this?".

Anyway, the instructions cover most of what's required but someone's asked me to set this up to take the first 3 characters of a company name (I can do that), followed by 2 numbers for the year (eg 12, 13, etc) and then a 5 digit auto number (I can do that) so it would look like CON1200001.

What my question is - is there a way to get a 2 character year number in the auto number?

I'd written some JavaScript code that did this quite nicely when the form loads but it was when we started importing records that the problems started because it, obviously, doesn't run the code.

preitmeyer Oct 24, 2012 at 10:52 PM 
I've never used this solution before, so Im no expert at this, but I am a CRM expert who's been using CRM for 10 years, so I think I can answer this one. Basically all you need to do is create another field on your child entity called new_xxx as you had on your parent entity (Opportunity). Then in the relationship 1:N of your custom entity between Opportunity and the custom one, click "Mappings" on the left hand navigation and create a map between the Opportunity new_xxx and the Sub-entity new_xxx. This mapping will automatically pre-fill the new_xxx on the sub-entity once its created, assuming its always created from within the bounds of the Opportunity form. Then using this auto-numbering solution, you'd be able to do exactly what you're looking for, and simply pull the new_xxx field into the equation.

Caveat, if for whatever reason you do not *always* create the Sub-Entity from the bounds of the Opportunity form, and users have to lookup the Opportunity value onCreate, then you need to create a Pre-Create plugin that gets the context of the Opportunity record and fills in the new_xxx field before its created, this way the Plugin for the Autonumber will fire with the proper fields filled out.
Hope that helps!
-Paul Reitmeyer

ClickOnCRM Oct 15, 2012 at 1:01 PM 
Hi. Great Job, XMRBits. Thank You.

Can you help with the following please.

We are using the opportunity entity as our main entity to generate our first auto number sequence, using your system and it works fine. (new_xxx) shows as XXX-00001

1. We have created a 1:N sub entity (like Opportunity Products) and we want the new_xxx number above to form the basis of the sub entity, so that it will show XXX-00001-01. How do I access the opportunity.new_xxx field to make this happen. I have tried many variations (as per your examples) but have been unsuccessfull.
2. I also want to start a new sequence of sub numbers in the child entity for every new opportunity. I.e. I want to have XXX-00001-01 up to 99 (maximum) Then I want to see XXX-00002-01 to 99. I was thinking I could possubly use the record count for that subset, but I would not know the code. Can you help or suggest an alternative way please.
Thanks so much.