Can we add a field on an existing workitemtype?
-
Thursday, October 20, 2011 1:40 PM
Hi,
I'm using TFS API and i would like to add field to a existing workitemtype.
I know the "manual" way with TFS power tool in VS2010. But i would like to do it by code.
With the TFS API, we can retreive a Workitemtype, modify it, and push it back into TFS.Do we have another way to acheive this by code? Like WorkItemType.Fields.Add(My custom fields).
All Replies
-
Monday, October 24, 2011 7:41 AMModerator
Hello acidaddict,
Thanks for your post.
For your issue I have to say that it is possible for you to export or import one work item type programmatically by using TFS API, however, it is not possible for you to add one field to the work item type with TFS API.
Actually, all the fields are stored in the FieldDefinitions property of the WorkItemType class. The FieldDefinitions is the FieldDefinitionCollection type which consists of couples of FieldDefinition. And in order to create one new field in one work item type, you need to create one FiledDefinition first. However, all the properties in the FiledDefinition class are read-only (only have Get(), not Set()), so you can’t create one instance of FiledDefinition class. So you can not create one field programmatically.
For further information about how to export and import work item type programmatically, please refer to these following two blogs:
Thanks.
Vicky Song [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marked As Answer by acidaddict Monday, October 24, 2011 3:32 PM
-
Monday, October 24, 2011 3:32 PM
Thanks Vicky Song
I'm doing export / import right now with the API.
The API in the actual form can't add field by FieldDefinition like you said.
That's answer my question, have a nice day!

