Recently I was working on a project that required a lot of plugins and workflows to carry out a variety of calculations on data, however the calculations made use of a lot of variables that changed regularly (a few times a week say).
Therefore, the values could not be hard-coded by the plugins and needed to be easily editable by the users. Initially I thought parameters would be the solution to this problem, the users could simply go in to the customisations and change them? Then I thought of a much cleaner way to achieve the same functionality, a configuration entity. The use of a configuration entity solves 3 problems here, firstly the everyday system users should never have to go into the customisations and make changes on a regular basis, even if they are just to process parameters. Also, a lot of the same parameter values were being used in several different processes and plugins and related to that, plugins can't have parameters in the same way as workflow processes.
The idea is that you create an entity with a field for each value required, users can then access this entity in the front-end system and change the values to be used in the processes. The processes access the parameters stored in the configuration record(s) by performing a simple retrieve on the configuration record(s) required and storing the required values in variables at the start of each execution.
This concept could obviously be applied in any Dynamics CRM system that had to make use of regularly changed values in its processes and plugins.
Showing posts with label plugin. Show all posts
Showing posts with label plugin. Show all posts
In this article I am going to show you, step-by-step, how to auto-number your records in Microsoft Dynamics CRM 2011.
* This article assumes you already have your environment set up.
- First, create a new solution with a name of your choice (I've called mine "JacksSolution").
- Create an option set in the solution called 'Prefix & Suffix Options', and give it the following options:
| Option Set Options |
|---|
| Free Text |
| 2-Digit |
| 4-Digit |
- Create a new entity called 'Auto-number'.
- Create the following fields on the entity:
| Display Name | Field Type | Schema Name |
|---|---|---|
| Entity Name | Single Line of Text | jack_entity |
| Field Name | Single Line of Text | jack_field |
| Counter | Whole Number | jack_counter |
| Increment Unit | Whole Number | jack_incrementunit |
| Number Formatter | Single Line of Text | jack_numberformatter |
| Prefix | Single Line of Text | jack_prefix |
| Suffix | Single Line of Text | jack_suffix |
| Prefix Separator | Single Line of Text | jack_prefixseparator |
| Suffix Separator | Single Line of Text | jack_suffixseparator |
| Prefix Type | Option Set | jack_prefixtype |
| Suffix Type | Option Set | jack_suffixtype |
- Arrange the fields neatly on the form, like so:
- In this example we are going to automatically number the Invoice entity, so go to the Invoice entity, add a field called 'Invoice ID' of type single-line of text and place it somewhere obvious on the form.
- Now, create a new JavaScript web-resource with a name of your choice and add the following JavaScript from the linked file to the file in CRM:
- Go back to the Auto-number entity and call the AutonumberOnLoad function on-load of the form.
- Also add the OnPrefixSuffixTypeChange function to the on-change event of both the 'Prefix Type' field and the 'Suffix Type' field and pass in the name of the calling field in string format as the parameter (in my case 'jack_prefixtype' and 'jack_suffixtype').
- Create a new auto-number record in the system and fill in the details, I used the following:
- Now comes the plugin itself, you will have to create one for each entity you wish to automatically number.
- For this example, create a new plugin to fire pre-operation on-create of the invoice entity and add the code found in the following text file:
- Deploy the plugin to the auto-number solution.
- Now, create a new invoice and hey-presto, its been numbered!
This component can be easily modified to work with any entity in the system, including custom entities.
Subscribe to:
Posts (Atom)


