2 workflow instance executes at same time


Badge +6

I am working in Nintex 2013 (and Sharepoint 2013).

Requirement: When employee joined the company, employee details are entered in SharePoint list Employee and after save Unique ID is generated. This ID is fetched from GenerateID list which has 1 row 1 column. 

During save of list item, Nintex workflow fetch latest ID from GenerateID list and Increment it with 1 and assigned it to column Employee ID (Latest ID + 1) in Employee list and override this latest ID in GenerateID and for another new Employee it will do the same activity and so on. In short, every Emp should have unique ID.

Issue

this application is used across location which result in duplicate ID - may be multiple Admin. clicks on SAVE button at same time. This rarely happens, but what could be fix for this. How to restrict workflow instance to stop till earlier workflow instance finish its activity. 

- Chintan


16 replies

Userlevel 5
Badge +14

sharepoint doesn't provide OOTB any (reliable) unique ID/sequencer generator (apart from item ID). so you can avoid situations like you described.

either you will rely on item ID or you have to use some external source.

see as well following links

how to query for site content type  

 

Badge +6

Hi Marian, your link shows how to generate ID, that i already achieved it. My concern is during generating ID, 2 users clicks the save button at precisely the same time/second which in turn make workflows instances execute the same item which result in 1 workflow wins and other goes to failure. 

Userlevel 5
Badge +14

you haven't mention anything about workflow failure in your post...

I understood it you want to resolve duplicated IDs.

there is no way how you could serialize updates to single item.

what you could do in case of error is that you try to repeat the operation. but that would resolve just update operation on GenerateID list itself.

but that will still not resolve problem of getting the same ID for two or more employees!

furthermore, depends on what exactly you do between reading and updating of GenerateID list, it may happen that longer running workflow sets back current ID  by several values.

Badge +6

Isn't it an option for you to create a Unique ID with the help of current time stamp or something like this?

Userlevel 5
Badge +14

discrete interpretation of time in digital world IS NOT unique.

and in sharepoint, with (mostly) minutes-level precision or even (rarely) seconds-level precision, definitely not.

Badge +6

Ok if you only use the stamp you're right, but if the seconds are included I think it's very unlikely that there'll be duplicates.

What do you think about a combination of the List ID and the Element ID? ;-)

Badge +16

‌ this is the perfect scenario for you to blog about that awesome ID fetcher thing you did...

Userlevel 5
Badge +14

I think it's very unlikely that there'll be duplicates

Murphy's laws say, if anything can happen it will definitely happen and will happen when you expect it the least and when it can cause the most problems happy.png

if you want to ensure uniqueness, you have to use reliable source that in no circumstances returns a duplicate value.

What do you think about a combination of the List ID and the Element ID

nice combination happy.png, was that the question?

but seriously, I'm not sure what you exactly mean with 'list ID'. is it  list's GUID? or item's ID within the list? or anything else?

and I'm totally not sure how should I understand 'Element ID'.

can you provide some example/further explanation?

Userlevel 5
Badge +14

I'm eager to read about it ... happy.png

Userlevel 3
Badge +9

Just for the sake of accuracy, Murphy's law states that "Anything that can go wrong will go wrong."  Certainly anything can happen, even something going right.  But Murphy does not concern himself with things going right...only when things go wrong.  happy.png

~Murphy

Userlevel 5
Badge +14

I'm very sorry for not quoting *your* life-long truths accurately  laugh.png

saw it very very unlikely you would have caught just my post,  but Murphy's laws had applied laugh.png

Userlevel 3
Badge +9

No problem.  It's known among Murphy's that "Anyone that can quote Murphy wrong, will quote Murphy wrong". laugh.png

Userlevel 5
Badge +14

Like it happy.png

Badge +6

finally, I have settled down with Constant & item ID combination, which will always be unique.

Userlevel 5
Badge +14

wise decision.

Userlevel 4
Badge +7

‌ please have a read of this blog plost (as prompted by ‌)

Hope it can help.

Reply