It's all about the answers!

Ask a question

Define a unique/continous ID for a specific work item type?


Frank Ning (50024117132) | asked Jan 23 '13, 8:29 p.m.

Hello,

There is a need to have an integer attribute for a specific work item type which will start with 1 and keep increasing sequencially/continously when new items are (being) created.

What is the (best) way to implement this (including the coverage of synchronization if multiple users are creating new work items at the same time)?

Thanks  much in advance

2 answers



permanent link
sam detweiler (12.5k6189201) | answered Jan 23 '13, 9:37 p.m.
write a participant plugin which generates the number after the workitem is saved, and updates the workitem

Comments
Frank Ning commented Jan 24 '13, 4:45 a.m.

1. Can this be done with JavaScript?

2. Do you just update the default value of an attribute which can be shared among all work items?

3. Do we have race conditions if multiple accounts are saving multiple work items almost at the same time? Are we able to "lock" the attribute before new value is updated? Or you have another smart way to handle this?


permanent link
sam detweiler (12.5k6189201) | answered Jan 24 '13, 8:10 a.m.
the problem with Default value (and javascript implementation) in my mind is that the number needs to increment before it is shown, and the save of the workitem could be abandoned, thus causing gaps in the numbering.

if you don't care about gaps in the numbering sequence. My users would ask, why are 4, 20 and 27 missing, and I would have to go off and figure out why,. is it a bug, or an operation problem, or result of some user action..

race conditions are always fun the persistent storage of the last assigned number will need to be someplace reliable.. a web service maybe..

so, for me the participant gets the next number from the web service, which implements all the concurrency/race condition handling code.
the workitem is already saved at this point, and you get the unique value (guaranteed from the web service) and apply it to the workitem presented to the participant.

Your answer


Register or to post your answer.