Click here to Skip to main content
13,449,583 members (52,803 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 4 Jul 2013

TFS Auto Complete Fields

, 4 Jul 2013
Rate this:
Please Sign up or sign in to vote.
TFS auto complete fields.

In TFS you are able to customise your process template and one of the rules you can add to a field is a SuggestedValues rule, with this you can specify many single items for suggestions or/and get the suggestion items from a global list. This works great for if you have a set list of suggestions, but what if you want to pull your suggestion list based off data in TFS.


Reading this we are assuming that you have a understanding of the basics of customising a process template.

Create the Magic

Add a field

Add a new field to any work item called The Auto Completing Field. Make it’s reference name be Fields.The.Auto.Completing.Field. Leave the type as string and import the work item definition into TFS.

Create a Team Query

Browse to any of the interfaces where you can create a flat query. Start a new Query,


And for this example create your query as below.


For Column options select just the “The Auto Completing Field” field, and in the sort columns select the same column. Save that query in the root of Shared queries.

Creating the server plugin

The plugin you will create is very simple and you will be able to use the source attached directly. Basically what you are going to do is whenever the configured fields are changed then you will call the query mapped to that field and update a global list which you will add as a suggested list for your field after the global list is created.


The code that does the logic magic is below and all the classes being called are in the source download

Uri requestUri = GetTFSUri(requestContext);

foreach (StringField field in workItemChangedEvent.ChangedFields.StringFields)
    if (DoesFieldNameExistsInConfiguredFields(configuredFreeTextFields, field.ReferenceName))
        IGlobalList globalList = GlobalListFactory.GetGlobalList(requestUri, 
          _configuredFreeTextAutoCompleteGobalListPrefix + 
          field.ReferenceName.Replace(".", "_"));
        IQueryRunner queryRunner = 
          QueryRunnerFactory.CreateInstance(requestUri, workItemChangedEvent.PortfolioProject);

        WorkItemCollection workItemsFromQuery = 
        foreach (WorkItem wi in workItemsFromQuery)
            if (wi.Fields.Contains(workItemsFromQuery.DisplayFields[0].Name))

The bits of code around the above code load configured fields from the app settings. A default example of what the config would look like for the field created in this article is below.

<add key="AutoCompleteSettings.AppSettingsPrefix" value="AutoComplete." />
<add key="AutoCompleteSettings.GlobalListPrefix" value="AutoComplete_" />

<add key="AutoComplete.Fields.The.Auto.Completing.Field" 

  value="<Your team name>/Shared Queries/The Query we just created" />

Final Touches

The server plugin should create the global list for you if it doesn’t exist, so if you go into TFS and alter the “The Auto Completing Field” then the global list for the field will be created, alternatively if you are using the default configuration you can import a global list upfront called AutoComplete_Fields_The_Auto_Completing_Field.

Basically after the global list is in TFS (no matter which method you use to get it there), you need to go back to your work item definition and add the SuggestedValues rule that uses the global list created as it values.

Publish the server plugin and import the changes made to the work item definition and we’re done =)


This plugin allows you to give users the flexibility to use free text fields and by making a auto complete type experience helps a bit to not have multiple values for the same thing that will later make accurate reporting slightly tougher.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Gordon Beeming (RSA)
Software Developer Nologo Studios
South Africa South Africa
Gordon Beeming works at Nologo Studios in the sunny city of Durban, South Africa. He is the Lead for the Data and Services Team and has a strong focus on Developer Efficiencies and R&D. When he's not hacking away at a keyboard in Visual Studio he'll generally be relaxing with his family or hitting the black top getting in some mileage. He is a Visual Studio ALM Rangers, Visual Studio ALM MVP.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
johannesnestler14-Jan-14 3:26
memberjohannesnestler14-Jan-14 3:26 
GeneralRe: My vote of 5 Pin
Gordon W Beeming14-Jan-14 3:31
memberGordon W Beeming14-Jan-14 3:31 
Questionreply Pin
Member 1016024518-Jul-13 8:22
memberMember 1016024518-Jul-13 8:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180318.3 | Last Updated 4 Jul 2013
Article Copyright 2013 by Gordon Beeming (RSA)
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid