Work Item customization - referring other work items in dropdowns

While customizing the process template

- created work item A
- creating work item B, want to use a dropdown that lists all work items created of type A

i.e If there are work items called Parts and Machine, want to access a dropdown of all created Parts in the Machine work item

What is the syntax for doing the same - This is not the case of a global list

Is there a specific syntax of AllowedValues that can read from instances of a work item?

Regards

[467 byte] By [mat_net] at [2008-2-20]
# 1

We do not support something like that - our lists of values are just plain strings. However, if the list of work items of type A is changed infrequently, you may go with the global list solution:

- Define a global list which will be populated with the list of work items of type A
- Define work item type B with the field taking its allowed values from that global list
- Update that global list regularly using glimport.exe.

AliakseiBaturytski at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 2

Thanks for the reply Aliaksei

But the problem is these are frequently changing work items, new ones are added and they need to be referenced in drop downs while creating other work items.

The global list option is going to be very tedious in this case
The Related work items also does not meet this req.

Read your blog
http://blogs.msdn.com/team_foundation/archive/2005/05/06/415268.aspx
Shall try that out and write in.

Is there a better workaround to this? Can we expect this in future releases?
Seems like this would be a frequently required feature.

Regards

mat_net at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 3

Unfortunately, there's no other workaround for that problem - our work item types were not designed with that goal in mind.

AliakseiBaturytski at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 4
had customized the template and added a new work item - 'CustomWorkItem', now trying to retrieve instances of this work item using the WI Object Model in VS 2005.

Faced 2 problems
- Got the error "Cannot connect to application tier", had to use VS with Run as - tfssetup user. Why this error? Have added the other user in Team Explorer - Permissions and given all permissions.
- After Run As - tfssetup, trying to retrieve the work item collection with the foll. code

TeamFoundationServer tfs = new TeamFoundationServer("ServerName");
WorkItemStore store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
WorkItemCollection wic = store.Query("SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.TeamProject] = 'XYZ' AND [System.WorkItemType] = 'CustomWorkItem'");

Got the collection, that has the right count, but when trying wic[0].Title, get the error
threw an exception of type 'Microsoft.VisualStudio.Currituck.Client.DeniedOrNotExistException'
"The CustomWorkItem type does not exist."

Does the Work item type defintion need to be present at TFS clients?
Needed this list of instances to update the global list at the server.

mat_net at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 5

Mat, you were saying that you customized the template. Do you remember how you imported it after that? I.e. did you use witimport.exe or template manager from the UI? If the latter is true, you should be aware that modifying the template does not update existing work item type definitions; the templates are used only for creating new projects.

Anyway, the exception you see should not have happened; I will investigate this issue.

Question: can you tell whether you added a new work item type or edited an existing one?

AliakseiBaturytski at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 6
Aliaksei, thanks for the reply.
I'm creating a new process template but the base files are a copy of the MSF Agile files folder. Changed them (added new WITs) and imported as a NEW template into VSTS. (used the UI manager)
Did not use witimport as this is a totally new template. When i make some small changes, for testing i use the witimport for a project where the new template is being used.

Scenario
- TFS Server & AD on a server
- TFS Client with domain login on a workstation
- This domain user has been added at the TFS Server root in Team Explorer and given all rights.
- Had imported the new template at the server, even tried from the client
- Running the app that uses the WIOM on the client

Regards

mat_net at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 7

So, you had created a new template and uploaded it on the server. But did you create a project using that template after that? If not, your changes were never applied.

As I said earlier, templates are only used for creating new projects, modifying an existing template has no effect on work item types created with that template.

Having said that, I still believe that the exception you're seeing when accessing Title property of the work item type is caused by some bug in our code which I am trying to reproduce.

Thanks,
Alex

AliakseiBaturytski at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 8
- Exported MSF Agile template
- Copied those MSF Agile files to a new folder for creating a new template
- In new folder, made changes (added new WITs) etc.
- Imported this as a new template
- Created a Team Project based on this new template
- Now using the WIOM for this project to retrieve the work item collection

TeamFoundationServer tfs = new TeamFoundationServer("ServerName");
WorkItemStore store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
WorkItemCollection wic = store.Query("SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.TeamProject] = 'XYZ' AND [System.WorkItemType] = 'CustomWorkItem'");

Got the collection, that has the right count, but when trying wic[0].Title, get the error
threw an exception of type 'Microsoft.VisualStudio.Currituck.Client.DeniedOrNotExistException'
"The CustomWorkItem type does not exist."

Running this code on the machines where VS 2005 with TF client is installed

mat_net at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 9
Hi Alex, any hope?
mat_net at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...
# 10
Hi Mat,

I cannot repro your scenario - if query returns non-empty set of results, accessing wi[0].Title doesn't throw any exception. If the result set is empty, wi[0].Title throws 'index out of bounds' exception, which is OK - there's no item 0.

It seems like you're using an old build of TF - in Beta 3 the TeamFoundationServer class doesn't have a public constructor; in that version you would have to write something like that:

WorkItemStore store = new WorkItemStore("yourservername")

One more advise: the UI is built on top of the OM; running a query will call same methods that you're calling. Could you check if you can run a query like that in the UI? Make sure you add System.Title to the list of result columns.

Thanks,
Alex

P.S. Sorry for the late reply - we were pretty busy here...

AliakseiBaturytski at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Microsoft Solutions Framework (MSF)...

Visual Studio Team System

Site Classified