Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

CRM2011: AutoNumber Causing Duplicates Since CRM Upgrade

$
0
0

We delivered a Plug-In that would give us the next numerical number within a sequence. The code is launched via a Plug-In watching for the Create event.

To ensure the Plug-In didn't allocate the same number to more than one individual we protected the code handling the number retrieval by using the following:

private static object _lockProcess = new object();
lock (_lockProcess)
{
    // Get next number code
}

The records the benefiting from having the next number assigned to them are created by workflow. So it's possible to have multiple records created at the same time... each requesting the next number in the sequence.

This has worked fine for 18 months, but recently we noticed pairs of records being assigned the same number. We've come to the conclusion that the Workflow engine must have changed and it's using more than one process or thread to allocate work.

When our workflow created 10 new client records at the same time we ended up with 5 pairs of duplicate numbers. So it seems fair to say that two threads or processes must be being used by the workflow engine now.

Is there a way to get the LOCK mechanism to protect our code, or do we need to seek a SQL based solution to allocate sequential numbers for new records?

Any advice gratefully received.

Steve


Viewing all articles
Browse latest Browse all 10280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>