21 Mart 2012 Çarşamba 10:51
i created a plugin for auto-number in ms crm 2011 and registered through Plugin Registration Tool on update of the record (using some condition to generate only one number per record)
Registered in pre-operation, synchronous and server. it is working fine but some times it's not.
My problem is some times the auto-number skips.
here 302 record is missing. but i found that 302 is created and changed to 303.
Note: I always open the record and update the entity several times using diff forms. but only some records like 302 were changed.
i believe that in online ms crm 2011 while same time several users where loggin that time it causes the problem.
Kindly help me
thanks and regards
10 Mayıs 2012 Perşembe 05:57
How are you referencing the auto-numbering increment?
Try using a controlling "reference" record in a custom entity, where you store the latest increment, and then when a record is created it grabs that number and increments by one.
Be sure to use a Mutex to lock the reference record, this will prevent duplications.
Using the entity will allow you reuse the plugin across multiple entities with a switch to detect your requesting entity and use the particular class, you can extend it to adding prefix, suffix, lengths etc for a particular entity rather than having multiple plugins.
10 Mayıs 2012 Perşembe 06:06
I believe the reason of the skipping numbers is due to concurrency issue.
When you are doing the lock / mutex, be aware that this is only works for single server configuration. When it comes to multi server configuration, you would have to do things slightly different.
Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits
10 Mayıs 2012 Perşembe 12:32Moderatörlocks.mutex are not guaranteed to work in plugins because plugins can be executed in different processes in CRM 2011. If you want to 100% guarantee uniqueness you need to implement a lock on a local resource such as a file or a database table. There are some 3rd party solutions that can do that for you as well.
Gonzalo | gonzaloruizcrm.blogspot.com