Simplifying, CRM & xRM

Dynamics CRM Formula Of The Week – Auto Number Generation

Scenario Overview

You need to generate an AutoNumber for the Account entity within the

Account Number field. The format of the AutoNumnber needs to meet the following


  • Have a prefix of “Acc-“
  • Followed by a fixed nine digit number left padded with zeros
  • A number starting at 1,000 incrementing by 1 each time a new Account record is created

Formula Manager Solution

Formula Managers solution to this is to build a formula which will,

  • Execute on the create of Accounts within the system
  • Have a formula that generates the auto number requirements
  • Have the formula place the result of the formula into the Account Number field of the Account entity
Dynamics CRM - Formula Manager - AutoNumber

Formula Manager Steps

The following set of steps outline how to create this Formula

  • Create a new Formula with Dynamics CRM taking the default name for now
  • Set the Formula Type field to “Auto Number”
  • Set the Auto Number Field to 1,000. This is the starting point for the auto number generation
  • The Pipeline Stage is set automatically set to “PreOperation- Synchronous” for use. This means the formula executes within a transaction so if anything goes wrong with the saving of the record then the record will not be created
  • The Pipleline Event is set automatically to “Create”. This means the formula will only execute when a record is created
  • Set the Source Entity field to “Account”. This means the formula will only execute when an Account record is created
  • Do not set anything for the Source Property field
  • The Target Entity field is automatically set to Account for us
  • Set the Target Property field to Account Number
  • Set the Formula Description to,
  • Click the save button. You are now ready to test your formula.
  • Navigate to the Account entity & create a new Accont recrod. Verify that the Account Number field has been set to ‘Acc-000001000’

See Also


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: