Auto-increment a new work item field
-
Sunday, February 22, 2009 8:11 PMI'd like to amend the process template for a Change Control, so that when I add a new CC, it is assigned a unique number within the change controls. Similarly for bugs.The intention is that I can have Bug #1, Bug #2 etc, and also Change Control #1, Change Control #2, rather than have my users referencing the system ID field.I'm able to add the new field with the process template editor, and lay it out on the screen, but I can't see how to get it to auto-increment. Please could you help?Many thanks,Mike
All Replies
-
Wednesday, February 25, 2009 2:47 AMDoes the Change Control represent a field? Do you want to make it unique every time you create a new work item with this field?
Please mark the replies as answers if they help and unmark them if they provide no help. -
Sunday, March 01, 2009 7:21 PMhi,No, I plan on keeping the Change Control as a separate type, just like Bug is a separate type. These types have 90% of the functionality I need, especially now I've worked out how to configure the Workflow.The intention would be to add a new field to each category, one called 'Our Bug #' and the other 'Our Change #', for the sake of argument.My issue is that our Test Team want to have their bugs auto-numbered, and in a logical order i.e. Bug 1, Bug 2 etc. We also want to have our change controls similarly logically ordered. This will help us to see how many of each we have, as well as give us simple sequential numbering.At the moment, I only have the system ID field, but of course this is sequential across all types, so I have gaps in the bug numbering where the change controls appear etc. Whilst this is fine for those of us with an IT background, our users and Test Team see this as a weakness of the system.[In fact, I'm going to an HP seminar on Wednesday where they're going to try and sell me their Quality Centre package, and I'm pretty sure our Test Lead is going to ask if bugs can be auto-numbered using that! I'm afraid he rather sees Team Suite as a techie-package and not really suitable for enterprise users. I'd really like to head this off if I can.]I'm really struggling with this. If you can offer any help, I'd really appreciate it.thanksMike
-
Sunday, October 25, 2009 5:47 PMMike,
There isn't a great answer for this scenario. As you suggest, you can add the field with the PTE, however there is no built-in autoincrement capability.
You could tie into TFS eventing: http://msdn.microsoft.com/en-us/library/bb130154.aspx
You could create an autoincement service and register thsi service to be called when a WorkItem is Changed (WorkItemChangedEvent). When the event is called, you could check to see if your custom field has a value and if not assign the next incremental value based upon the work item type. It would be your responsiblity to do the incrementing.
There is a good article written by Brian Randell in MSDN Magazine for creating this type of extension: http://msdn.microsoft.com/en-us/magazine/cc507647.aspx
Aaron Kowall

