Manage Global List in TFS API 2010

GLOBALLIST is shared XML configuration across all team projects for a specific team project Collection, we can you use it for many workitem types to share the same list.

Usually when you want to add/remove item from the GL you would use the command line tool (widadmin) or if you install team foundation power tools [TFPT] you can import/Export using visual studio tools-> process editor. even though, needless to say that business users are not knowledgable in managing technical details such as XML configuraions..

to manage workitem you to have a TFS permission

  • To export GL you should be member of team foundation valid users.
  • To Import GL you have to be member of team foundation administrator or project collection administrator.

below is step by step to write simple tool for managing Global Lists, you can download the source code here.


  1.  Create new Windows application.
  2. In the Main page add these controls
  3. add this global variables in Main class form, these variables will be used in many place in the form
  4.         #region Global Variavles
            TfsTeamProjectCollection serverCollection;
            WorkItemStore store;
            XmlDocument _globalList;
            public string GLitem { get; set; }
            public override string ToString()
                return GLitem;

  5. In click event for select Team project button add this code
               //showup the team project collection selection form
                TeamProjectPicker _teamProject = new TeamProjectPicker(TeamProjectPickerMode.NoProject, false);
                if (_teamProject.SelectedTeamProjectCollection != null)
                    serverCollection = _teamProject.SelectedTeamProjectCollection;
           = (WorkItemStore)serverCollection.GetService(typeof(WorkItemStore));
                    //call method to fill the list combo box.
            /// <summary>
            /// this method is to Export and bind All GlobalList in TFS collection
            /// </summary>
            private void BindingGL()
                //Get Global Lists from TFS collection
                _globalList = store.ExportGlobalLists();
                //read the XML and get only the GLOBALLIST element.
                foreach (XmlElement _element in _globalList.GetElementsByTagName("GLOBALLIST"))
                    //remove any global list for builds/ usually each system has global list of builds.
                    if (!_element.Attributes["name"].Value.ToString().StartsWith("Builds"))
  6. Add SelectedIndexChanged event for combox_GlobalLists to add values to the listbox
  7.         private void combox_GlobalLists_SelectedIndexChanged(object sender, EventArgs e)
                //clear the exist values.
                string globalList;
                //read the selected value.
                globalList = combox_GlobalLists.SelectedItem.ToString();
                //read and fill the list box with all items in selected global list.
                XmlElement _globalListElement = (XmlElement)_globalList.SelectSingleNode("//GLOBALLIST[@name='" + globalList + "']");
                foreach (XmlNode _node in _globalListElement)
                //add this static value to add new value.
                list_globalListValues.Items.Add("<<Add New Item>>");
  8. Now try to run the application, the load for the all global list and values should work.
  9. To add New values or Edit existing values i used the list box events, since the double click on any item will open edit sub form and double click on “<<Add New Item>>” it will open add new sub form.
            private void list_globalListValues_DoubleClick(object sender, EventArgs e)
                if (list_globalListValues.SelectedItem.ToString() != "<<Add New Item>>")
                    GLitem = list_globalListValues.SelectedItem.ToString();
                    GLEditForm _form = new GLEditForm(GLitem, Common.ChangeType.Update.ToString());
                    GLitem = list_globalListValues.SelectedItem.ToString();
                    GLEditForm _form = new GLEditForm(GLitem, Common.ChangeType.Add.ToString());
  10. The Delete operation is the same for add/update values, i used the “Delete” keyDown event in the GL
    private void list_globalListValues_KeyDown(object sender, KeyEventArgs e)
                //check if the key process is delete
                if (e.KeyCode == Keys.Delete && list_globalListValues.SelectedItem!=null && list_globalListValues.SelectedItem.ToString() != "<<Add New Item>>")
                    //remove item from the list
  11.  Now, after you have finish your changes for selected GL; you have to import your changes to TFS collection.
  12. Add Click event for Update globallist button
  13.             try
                    string GLName = combox_GlobalLists.SelectedItem.ToString();
                    //remove static value
                    list_globalListValues.Items.Remove("<<Add New Item>>");
                    if (GLName.Trim() != string.Empty && MessageBox.Show("Are You Sure you want to Update " + GLName + " GlobalList", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        XmlDocument _GLList = new XmlDocument();
                        XmlElement _valueList;
                        XmlProcessingInstruction _xmlProcessingInstruction;
                        _xmlProcessingInstruction = _GLList.CreateProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
                        //add new value to the XML
                        XmlElement GlobalRoot = (XmlElement)_GLList.CreateElement("gl", "GLOBALLISTS",
                        _valueList = (XmlElement)_GLList.CreateElement("GLOBALLIST");
                        _valueList.SetAttribute("name", GLName);
                        foreach (string _GLValue in list_globalListValues.Items)
                            AddValue(_GLList, "LISTITEM", _GLValue.ToString(), _valueList);
                        //Save GL to TFS store
                        MessageBox.Show("GlobalList Update Successfully");
                        list_globalListValues.Items.Add("<<Add New Item>>");
                catch (Exception ex)
  14. Enjoy The Tool 🙂
Enhanced by Zemanta

5 thoughts on “Manage Global List in TFS API 2010

    • Hello Fokko,
      Thanks for reading this post, i did check line 25 and it’s working fine with my the code.
      if you noticed next line (29) it’s store _GLList and then import it as xml using (ImportGlobalLists) method.

  1. Hey ,Great post!

    When I’m trying to update the global list I get :
    TF223006:You cannot modify the definition of a work item tracking object with your version of command-line tools as they are not compatible with the Web Services for Team Foundation Server. Contact your system administrator to determine how to upgrade your installation of team explorer to a version compatible with Team Foundation Server

    Any suggestions to how make it work?

  2. Hi,

    Fokko is right – he “AddValue” method is missing, it’s probably defined in your code locally but it is not in this post anywhere.

    Can you please add it? I have problem adding multiple nodes to the global list

Leave a Reply

Your email address will not be published. Required fields are marked *