Sunday, November 8, 2009

XRM Auto-Number Plugin (Online)

One of the most frequently asked features in xRM development is Auto-number @ Running Number generation process. Microsoft supports auto number generation for a few predefined entities like Contracts, Case, Invoice, Order etc.

Since I have been working in donation and clinical system projects, I found that most of our users request such feature in receipt number generation, reference number generation and document number generation processes. It is a quite common feature that they request.

There are a few ready-made CRM plug-ins out there. But most of them are only focus for numeric data type running numbers and cannot support for padding and/or auto number reset features. So, I decided to do it on my own way.

Let's take a look on the features of my Auto-number Plug-in:
  • This plug-in is supported only for server deployment and create message of any custom entity. 
  • Offline client does not need to register this plug-in since the number will auto populate when they sync back their offline data to CRM server.
  • Data type of running number attribute in custom entity can be either string (nvarchar) or integer data type. The rest is not supported.
  • You can specify auto reset number and padding format of running number in configuration setup.  Please check the screens below.
  • Prefix and Suffix values can be either fixed values or datetime ori ented values. Plugin will automatically parsed the value into date time format if  you provide datetime format in curly brackets:, for example {MM}-{yy} will be parsed into ’11-09’


Download Link:
Feel free to use this application.
Either leave comment or email me if you want to know further information.

38 comments:

Anonymous said...

Does this tool generate randum unique numbers as IDs to be used in account entity?

Thuta said...

Nope. It can generate only numbers in sequence. I will add random unique number feature in next version. Thanks for your idea and comment.

Thuta

Anonymous said...

Any Estimation as in when the next version will be published? thanks a lot.

Thuta said...

Sorry for my late reply. I planned to release my next version at the end of this year, probably in first week of January due to my busy time line. I planned to add a few more features on auto number generation plug-in ...

1. Allow to generate more than one pattern of sequence number on single entity based on some value
2. Random unique number feature as you requested, which is likely to be used in some organizations, and
3. My plug-in source code (haven't decide yet)

For random unique number feature, is there any specific pattern or requirements you want me to add in new release? Anyway feel free to contact me at my blog or my email. Thanks for your interest.

Anonymous said...

Can this plug-in be used to generate a unique number,every time an Appointment is created. The number will be stored within a custom attribute. Any details on how to set this up will be appreciated.
Many thanks

Thuta Hlaing said...

Hi,

Yes, it can generate unique number on any customizable entity in CRM. Please refer to my documentation file under download link section. If you have question, feel free to contact me at thuta@thuta.info. Thanks

Anonymous said...

Hi Thuta
Thanks very much for your plugin. I would like to genrate a number like 2010-001 where 2010 is the year and 001 till 999 is the running number. How can I configure "Autonumber" to display the leadin zeros of the number?

Thuta Hlaing said...

Hi,

Sorry, current version cannot support that kind of feature yet. It can generate only 2010-1. I will think of it in next version. Thanks!

Anonymous said...

Hi Thuta
Thanks for the fast reply.
Just one more thing what is the "padding" function doing? When and where is the padding character inserted?
Greetings from Switzerland!

Thuta Hlaing said...

Hi,

I updated my release already. Padding has some issue. Now it can work as you expected :)

Below is the configuration steps:
1. Prefix: {yyyy}-
2. If running number >=: 999
3. Use Padding Format: Left
4. With Padding Char: 0

For those who are using previous version, please follow the steps to update your plugin. (You don't need to re-register the step again.)

1. Download and extract Zip file
2. Open Plugin Registration Tool
3. Right click on PSXrmPlugins.AutoNumber
4. Click Update
5. On Update Assembly Dialog, #Step1: Choose new PSXrmPlugins.AutoNumber.dll file
6. Click Update Selected Plugin button

Thanks

Anonymous said...

Hi Thuta

Thanks so much for your work, will try this out first thing Monday!

Best regards.

Thuta Hlaing said...

Welcome my friend. Hope to hear good news :P

Anonymous said...

Hi Thuta

It works as expected!
Thanks a lot...

Gowri Shankar said...

Hi Thuta,

First of all, hats off to you for unveiling such a great add-on feature in MSCRM. I would like to know if this works for the records that are created via Workflows or Plug-ins. Also, if there are 10 records imported to CRM, those records shud also be numbered. Does your current release incorporate all these features?

Your earliest reply is appreciated. Thanks!!

Gowri Shankar

Thuta Hlaing said...

Dear Shankar,

To answer your questions:

1. I think, it will work for plug-in and Workflow created records because this plug-in is running at "pre-stage" of record create event.

2. If you are NOT using direct database import (which is also not recommended by Microsoft), I am sure it will work.

Hope it helps.

Best Regards
Thuta

rafael said...

Hello Thuta, your plug-in worked very well on our sandbox server, but when we tried to register it on our development server via gacutil.exe, we get the following error: Failure adding asembly to the cache: Unknown error.

Could you please let us know what version of .NET Framework you used to generate the dll? we are registering it using 1.1.

Thank you beforehand,

Rafael

Thuta Hlaing said...

Dear Rafael,

You may need to install Framework 2.0 in your development server. Below is the link for your reference:

http://www.microsoft.com/downloads/details.aspx?FamilyID=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=en

Hope it helps
Thanks

rafael said...

It worked with Framework 2.0.

Thanks a lot!

Rafael

Muzzman said...

Hi Thuta,

I don't normally do this but I can't for the life of me get this to work. We are running CRM on a Windows Server 2008 R2 64-bit machine and as you can guess things are a little different.

Here are the steps I followed:
1) Copied PSXrmDevLib.dll into the C:\Windows\Assembly folder of the server using a domain administrator account - no errors
2) Uploaded and imported psx_autonumber.xml into the CRM using my account (which is a CRM Systems Administrator) - no errors
3) Used Ajithg's plug-in registration manager v2.2. (from the MSDN code gallery) on the actual server to register PSXrmPlugins.AutoNumber.dll - no errors

At this point I could see Auto_Number as a custom entity.
1) I added it to the Settings Page
2) I have an existing custom entity called 'Issues' that I then added a custom nvarchar attribute called "Auto Number". I also added the "Auto Number" attribute to the default form as a read-only field.
3) I then created a new Auto_Number row, using 'Issues' and the "Auto Number" attribute, with the same settings as in your documentation
4) I then created a test 'Issue', saved it, then re-opened expecting the "Auto Number" field to be filled out but it wasn't.

So, am I doing everything right? Is it because it's a 64-bit server? Is there any logs I can check to see what it's doing?

Thanks so much!

Paul

Thuta Hlaing said...

Dear Paul,

You are right. This PSXrmDevLib dll file cannot support for 64-bit server. But you can download file from below link to get 64-bit compatible one. Hope this help!

http://sites.google.com/a/thuta.info/xrm-isv-file-hosting/home/PSXrmDevLib.dll?attredirects=0&d=1

Thanks
Thuta

Anonymous said...

Hello Thuta,
I have downloaded your plugin and tried to install it to our 2008 server (64bit) with the 64 bit compatiable Devlid.dll.
When trying to register the plugin.dll with the registration tool I received a error message.

(is partly in Dutch)
Unhandled Exception: System.IO.FileLoadException: Kan bestand of assembly PSXrmDevLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=075d500070353dae of een van de afhankelijkheden hiervan niet laden. De manifestdefinitie van de gevonden assembly komt niet overeen met de assembly-verwijzing. (Uitzondering van HRESULT: 0x80131040)

Can you help me what I did wrong? or how I can avoid this error?

Looking forward to your reply.

Regards,
René

Thuta Hlaing said...

Dear René,

Can you please check through below steps again?

1. Add 64 bit PSXrmDevLib.dll into GAC of your server
2. Copy plug-in dll file and registration tool into your server, and
3. Run plug-in registration tool to register the plug-in dll from server

If problem still exists, please let me know.

Thanks
Thuta

Anonymous said...

Dear Thuta,

Thanks for your reply. I did what you suggested..
I get the same error. It tells me that the found manifest definition of the assembly doesn't match the assembly reference....
What to do???

Regards,
Rrné

Anonymous said...

Dear Thuta,

First of all, thank you for your plugin.
We have deployed and test successfully in a couple of sandboxes.
However, trying to deploy it in a production server with HTTPS (that's the main difference from the sandbox) the following error appears when the number is about to be assigned to the entity:

Could not establish trust relationship for the SSL/TLS secure channel

Do you know what could be happening?

Thuta Hlaing said...

Dear René,

Sorry for my late reply. I was quite busy these days :)

I found the issue already.The public key token for XrmDevLib is not matching with my plug-in dll. I am testing on it since last night. Looks everything OK. I will release 64-bit version by tonight (around 11:00PM SG time).

Sorry for keep you waiting and thanks for your information.

Best Regards
Thuta

Thuta Hlaing said...

@Anonymous

Dear,

I haven't use it with SSL before. I will try to figure it out very soon. But, I may need your help for testing to make it work. :-)

Regards
Thuta

Anonymous said...

Hi Thuta,

Sure we will help you testing this issue. In fact, if you could share the plugin source code, maybe we could run some test in this scenario a report a possible solution.

Thank you in advance

Best regards

Thuta Hlaing said...

Dear René,

I uploaded the 64-bit plug-in already. You can get the file from download section in my post.

Best Regards
Thuta

Anonymous said...

Dear Thuta,

Thanks a lot it is working...
When I run it it counts up.
Only I cann't see the actual number in my enitity. I have made a field nvarchar and a Integer field but I don't see the number on the form. Can you help me one more time? I am so close... :-)

Thuta Hlaing said...

Hi,

Firstly, I create varchar(50) attribute in my entity. Then I put this attribute on the form and disabled it. This field cannot be mandatory.

Secondly, I make configuration setup as described in my post. I think that's all. May I know how you configure the steps?

Thanks
Thuta

Anonymous said...

Hi THuta,

THe last reply was also from me..
I have made a field LEnumber and made it as nvarchar and a other field named LEnumber2 as Integer. Disabled them both. When I make a new item then nothing happens, when I safe it and re-open it the field stay empty. And looking into the Autonumber entity the number is went up by 1.
Is it perhaps handy that I send you some screen dumps by e-mail?

Please let me know. Again thanks for your great help.

Regards,
René

Anonymous said...

Hi Thuta,
I have followed all of the steps from your article, but for some reason I am getting a message that "The request failed with HTTP status 401: Unauthorized".

I'm running CRM 4 UR11 on Windows 2008 R2. I didn't get any errors with the installation or configuration, just using the autonumber. I am logged in as a System Administrator...

Any ideas?

Regards,
Marcus

John said...

We have implemented this tool just as stated in the installation guide and filled in some values in getting autonumber to work in the Account entity, but the autonumber value does not show up on the screen. Can you help and tell what probably is going wrong here? We are working on a 32bit server.

Thanks in advance!

Fred said...

Hi Thuta, nice work!

Does it work with different organizations using same entity/attribute name?

Thanks! Fred

Anonymous said...

Hi Thuta, thanks a lot!

I have aquestion.
How to execute your plugin when an order is created from a quote? I thought that Triggering Pipeline set to Child Pipeline.
But this error occured.

"Only SdkMessageProcessingStep in parent pipeline and in stages outside transaction can create CrmService to prevent deadlock."

How to resolve or fix this problem.
How to catch the action which like an order is created from quote?

Thank you.
Maki

Anonymous said...

Who can drive me by any short film how to properly install this solution in CRM 2011 environment with Win2008R2 version of OS..?

Anonymous said...

Hi Thuta,
I have followed all of the steps from your article, it was working fine with on-premise but now we have configured IFD, after that for some reason I am getting a message that "The request failed with HTTP status 401: Unauthorized".

I'm running CRM 4.0 on Windows 2008 R2. I am logged in as a System Administrator.

Kindly guide us further.

Anonymous said...

Hi Thuta - in reading through your documentation, your solution is really amazing. Any chance that you will be releasing the source code? We would like to use your solution, but need to review the source code for security purposes.

Thanks for making this available!

Post a Comment