2

I want to programmatically create Iterations in my TFS Server, like here.

I got that code working, but my created Iteration-Nodes, are not behaving like expected.

What is working: the iteration nodes are created, and they can be linked to any Work Item. They can be selected, like shown in the picture below:

enter image description here

All Iteration nodes showing up as "Iteration*" were programmatically created. Other Iteration nodes (showing up as "Sprint*") were already there.

But the programmatically created Iteration nodes don't show up in the Backlog items view.

enter image description here

Only the "Sprint*" Iterations are there.

What am I missing to get my programmatically created Iteration nodes to show up there?

sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
Peter
  • 1,655
  • 22
  • 44
  • How are you adding these iteration nodes? Are you using the new REST API technology or the old TFS API technology for that? – sɐunıɔןɐqɐp Apr 25 '18 at 11:59
  • I'm not sure whether this works with the old TFS API, since I use the REST API. In this link you will find an example on how to create a product backlog entry: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/09655793-1679-48ff-82d2-cc0280544d3d/error-when-creating-product-backlog-item-via-rest-api?forum=TFService – sɐunıɔןɐqɐp Apr 25 '18 at 12:32
  • I am using the TFS API V15 – Peter Apr 25 '18 at 12:47
  • Actually I find them too in "Add Itterations" in the Manage Area of my TFS Web Page – Peter Apr 25 '18 at 12:48
  • @Peter Update your question to include your code. It's impossible to troubleshoot a problem with your code without **seeing your code**. – Daniel Mann Apr 25 '18 at 16:41
  • @DanielMann I really just create the itterations like shown in the linked answer. It think my question is more about general tfs itteration handling. – Peter May 02 '18 at 09:12

2 Answers2

2

I think you have to add iteration in team settings for default team (or any another). You may find example here: TFS 2012 API Set TeamSettings Programmatically

    // Set up default team sprint date and time
    var teamConfig = _tfs.GetService<TeamSettingsConfigurationService>();
    var css = _tfs.GetService<ICommonStructureService4>();

    string rootNodePath = string.Format("\\{0}\\Iteration\\Release 1\\Sprint 1", _selectedTeamProject.Name);
    var pathRoot = css.GetNodeFromPath(rootNodePath);

    css.SetIterationDates(pathRoot.Uri, DateTime.Now.AddDays(-5), DateTime.Now.AddDays(7));

    var configs = teamConfig.GetTeamConfigurationsForUser(new[] { _selectedTeamProject.Uri });
    var team = configs.Where(c => c.TeamName == "Demo").FirstOrDefault();

    var ts = team.TeamSettings;
    ts.BacklogIterationPath = string.Format(@"{0}\Release 1", _selectedTeamProject.Name);
    ts.IterationPaths = new string[] { string.Format(@"{0}\Release 1\Sprint 1", _selectedTeamProject.Name), string.Format(@"{0}\Release 1\Sprint 2", _selectedTeamProject.Name) };

    var tfv = new TeamFieldValue();
    tfv.IncludeChildren = true;
    tfv.Value = _selectedTeamProject.Name;
    ts.TeamFieldValues = new []{tfv};

    teamConfig.SetTeamSettings(team.TeamId, ts);

Name of default team: "YOUR_PROJECT_NAME Team"

Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31
1

The iterations which are selected in the teams setting will appear in the Backlogs hub for your team. Go to the team's setting, for example:

https://xxx.visualstudio.com/TeamProject/TeamProject%20Team/_admin/_work?_a=iterations

And select the iterations you want to show up in the Backlog hub, check the screenshot below:

enter image description here

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39