is it possible to extend a TFS Version Control Item with custom fields or properties?
Most entries found are about custom properties on TFS Work Items.
I want to keep a version control Item linked to a record in a database, using a set of custom properties that contain the db/table/primary key of the record.
Thanks, Rine
Team Foundation Server 2010 introduced a new feature called 'Properties'. Almost every item in TFS, be it a version control file/branch, or a work item can have a property bag associated with it.
What is missing from TFS 2010, is a generic UI to view/set these properties, however you can use the TFS Object Model to view/set them yourself.
For more information, see the following links:
Adding Properties to Artifacts within TFS 2010
Using the TFS Property Service to enrich your third party VS tools
MSDN documentation for Microsoft.TeamFoundation.Framework.Client.IPropertyService.
You delete a property by setting its value to null.
public static void DeleteGenericProperty( this IPropertyService propertyService,
string moniker, string propertyName, int version = 1 )
{
var artifactSpec = new ArtifactSpec(ArtifactKinds.Generic, moniker, version);
propertyService.SetProperty(artifactSpec, propertyName, (string) null);
}
Related
I am trying to customize a work item template and need to add a field which can capture hierarchical data.I am using TFS power tools to edit work items. I tried to create a new field with datatype as TreePath but when I save it, it throws an error:
TF26179 – Field Type 'TreePath' can be used only with System.AreaPath & System.IterationPath
Is there any workaround to use the TreePath control for custom fields?
This should be duplicated with this thread : TFS 2013: Custom TreePath Fields.
Just as the error message mentioned the Field Type 'TreePath' can be used only with System.AreaPath & System.IterationPath.
So, Tree Path is not supported for other fields for now, and there is a user voice submitted to request the feature, you can vote it or submit a new user voice to suggest the feature.
For custom control, you can reference the source code of the vsts-extension-color-control
You can't create a new field with TreePath data type, but you can create custom controls for other data types, so you can create custom controls that display hierarchical information as long as you are able to represent this in an existing data type, in practice the String type.
Examples of custom controls at https://witcustomcontrols.codeplex.com/.
I'm a new TFS Admin and have a request to create a custom field on Bug and Requirement work items that will contain the following data: Work Item Type + id + title. I can get the field created and the control added to the form. I just can't figure out how to get the selected values into the field. I'm trying to use the System.WorkItemType + System.Id + System.Title fields to populate the new field.
TFS natively doesn't support calculated fields like this. However, you can use a 3rd party tool (or write your own ISubscriber plugin) to accomplish it.
The TFS Aggregator tool might be able to do this for you: http://tfsaggregator.codeplex.com/
Using the TFS oData service I see only a generic WorkItem class which has a Type property. How can I access properties such as Mitigation, Contingency Plan, etc. for the Risk type, or Corrective Action for the Issue type?
Thanks
There is no specific class for each WorkItem, because you can customize and name them as you want, therefor the generic WorkItem class is used. If you want to get the value of a specific field, load the WorkItem and use following (with the fieldname you need):
wi.Fields["System.AssignedTo"].Value
We have a TFS team project using the Agile process template.
We have added a string field to the User Story and Task work item types.
This field is a dropdown bound to a global list.
When you create a new linked workitem from an existing workitem (using the NEW button on the LINKS tab for example), the Assigned To, Area and Iteration values are copied to the new linked item.
We would like to also copy the value for the string field that we've added, so that it does not have to be set manually.
Any ideas if this is possible using TFS customization?
It's possible... but not with "out of the box" work item features. You'd need to write some custom code with the SDK (http://archive.msdn.microsoft.com/tfssdk) to get this behavior.
I'm implementing a web interface for TFS bug tracking system, so customers can log in and enter bugs. In here I want to add fields according to the template type of the VSTS team project created. For example, a team project created using 'Agile' template has different set of fields than other templates. Therefore I want to identify the process template of the team project at the beginning.
But "Microsoft.TeamFoundation.WorkItemTracking.Client.Project" does not contain a field for template type. So how can I identify the process template type of the team project?
The direct answer is to call GetProjectProperties.
However, I agree with John that you may be tackling a harder problem than necessary. Certainly you'd agree that writing a fully generic WIT client is hard. However, work item customization is very common, even within organizations that use a standard process template. So you probably can't get away with a one-off solution, unless you're willing to update it every time a project admin updates their bug template.
Is there some reason WIWA doesn't work for you? (Note that the download link isn't valid anymore; it's now part of the broader TSWA SP1 release.)
Also remember that any such application that's available to customers (not internal staff), whether WIWA or something you write yourself, requires an "external connector license" according to the TFS CAL model.
I don't know the answer to your question, but have some points to make:
I edited your question to make clear that you're asking about Process Templates
I also clarified that you're talking about Team Projects, and not Visual Studio project files. These two edits together should keep people from thinking you're asking about the things that show up when you use File->Add New Project.
Finally, you should consider that process templates can be customized. You may want to organize around the set of fields, instead of by the template, unless you need information about the template itself.
I actually used the following code:
static void GetProjectTemplate()
{
string collectionName = "http://<our_host_name>:8080/tfs/defaultcollection/";
TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(collectionName)
, new UICredentialsProvider());
tfs.EnsureAuthenticated();
ICommonStructureService css = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));
string[] projects = { "proj1", "proj2", "proj3" };
foreach (string proj in projects)
{
ProjectInfo projectInfo = css.GetProjectFromName(proj);
String projectName;
String prjState;
int templateId = 0;
ProjectProperty[] projectProperties;
css.GetProjectProperties(
projectInfo.Uri, out projectName, out prjState, out templateId, out projectProperties);
Console.WriteLine(templateId);
}
// Locate templateId in the list of Process templates
IProcessTemplates processTemplates = (IProcessTemplates)tfs.GetService(typeof(IProcessTemplates));
XmlNode node = processTemplates.GetTemplateNames();
Console.WriteLine(Regex.Replace( node.InnerXml,"<[A-Za-z]","\n$&", RegexOptions.ECMAScript ) );
}
...copied and modified from here: http://www.databaseforum.info/30/1083827.aspx
Problem is, I still get '-1' as the template id. Does this mean the projects were created with no template? Also, I changed the project and host names above for posting here. (They are legitimate projects).
Instead of:
Console.WriteLine(templateId);
use:
Console.WriteLine(projectProperties[2].Value);