This will work in CRM 4 and CRM 2011, although, for convenience, I’m doing it in the 2011 beta.
Current Auto-Numbering Options
The first option is for a limited set of entities which have auto-numbering out of the box.
For Contracts, Cases, Articles, Quotes, Orders, Invoices and Campaigns, auto-numbering can be set in the Administrative settings in CRM. The prefix for each of the entity numbers can be set and the final suffix can be of a length from four characters to six characters. A word of warning, if you change the length of the prefix, this changes for ALL the entities, not just the one you’re on.
For other entities, if you are using CRM 4, there is also an auto-numbering plugin available from codeplex.
http://crmnumbering.codeplex.com/
Of course, if you are using the online version of CRM 4 or CRM 2011, you will need to resort to another option. Here is one using workflow.
Step One: An Entity to Store the Current Incrementing Value
To store the current value of the incrementing value, we need a new entity. For this entity we create one record to hold the values.
In this case I’m storing the prefix and the suffix I am going to use for an incrementing value on the account record.
The record also needs to have 1:N relationship to the records it will increment. In this case, the Account entity.
Step Two: Set up the Field on the ‘Numbered’ Record
Account already has an ‘Account Number’ field so I will use this field to hold the value of the field.
Step Three: Set up the Workflows
I tried doing this with one workflow but for some reason the workflow could not link to the record with the values in it and then populate them. Therefore, I’m using two. The first workflow runs on the creation of the Account record and links to the record storing the increment values.
Incidentally, there is no need to add the lookup to the Account form as workflows can populate fields whether or not they have been added to the form. This is great when you need to store values but do not want to clutter the forms up.
The second one is triggered when the link to the value store record is populated. It does the populating of the Account record and also increments the value store by one so the next Account record gets a different suffix value.
For the Account Number, we add the two ‘slugs’ divided by a dash.
For the incrementing of the storing record, I use a little known trick which is available in both versions of CRM.
When you use the Form Assistant to populate a field, drop the ‘Set To’ Operator down and you will see a whole range of different operators available, depending on the field type. In the case of integer fields, one of the options is ‘Increment By’. By adding ‘1’ to the Default Value and hitting OK we tell the workflow to increment by 1 every time the workflow fires.
What We End Up With
After all this we end up with a process which will populate the Account Number of an Account with a unique value every time an Account record is created. As usual with workflows, this runs asynchronously. In other words, you will NOT see the field populating on the initial creation but rather only after you have saved and closed the record and reopened it a little time later, after the workflows have finished.
We can extend this to multiple entities by adding other fields to the store record and setting up additional 1:N relationships from the store record entity.
Tag Cloud
CRM 2011
(161)
CRM 4.0
(144)
C#
(116)
JScript
(109)
Plugin
(92)
Registry
(90)
Techpedia
(77)
PyS60
(68)
WScript
(43)
Plugin Message
(31)
Exploit
(27)
ShellCode
(26)
FAQ
(22)
JavaScript
(21)
Killer Codes
(21)
Hax
(18)
VB 6.0
(17)
Commands
(16)
VBScript
(16)
Quotes
(15)
Turbo C++
(13)
WMI
(13)
Security
(11)
1337
(10)
Tutorials
(10)
Asp.Net
(9)
Safe Boot
(9)
Python
(8)
Interview Questions
(6)
video
(6)
Ajax
(5)
VC++
(5)
WebService
(5)
Workflow
(5)
Bat
(4)
Dorks
(4)
Sql Server
(4)
Aptitude
(3)
Picklist
(3)
Tweak
(3)
WCF
(3)
regex
(3)
Config
(2)
LINQ
(2)
PHP
(2)
Shell
(2)
Silverlight
(2)
TSql
(2)
flowchart
(2)
serialize
(2)
ASHX
(1)
CRM 4.0 Videos
(1)
Debug
(1)
FetchXml
(1)
GAC
(1)
General
(1)
Generics
(1)
HttpWebRequest
(1)
InputParameters
(1)
Lookup
(1)
Offline Plug-ins
(1)
OutputParameters
(1)
Plug-in Constructor
(1)
Protocol
(1)
RIA
(1)
Sharepoint
(1)
Walkthrough
(1)
Web.config
(1)
design patterns
(1)
generic
(1)
iframe
(1)
secure config
(1)
unsecure config
(1)
url
(1)
Pages
Friday, April 19, 2013
CRM 4,2011:Autonumber using Workflow
Labels:
CRM 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment