I am taking over a catalog of projects that already initiated. My job is to enter the projects into TFS and use the 'work' features. I am entering each project as an Epic...15 Epics total. When I enter an Epic is used the date I enter it as the project initiation day. Is there a way to grandfather in Epics in TFS. Adding Epics with a start date in the past? I cannot congigure the cumulative flow diagram properly without being able to back date entries.
Thanks
In Epics, the default field "CreateDate" can't be changed. It uses the date and time when the Epic created.
As a alternative, you can customize a field to use DateTimeControl, then you can select Date and change the time in this custom field:
There isn't any way to change the create date from TFS Web Portal. But if you create the work item via TFS API, you can enable the bypassrule which allow you specify the create date of the work item. Following is a code sample for this:
static void Main(string[] args)
{
string url = "http://collectionurl/";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(url));
WorkItemStore wis = new WorkItemStore(ttpc.Name,WorkItemStoreFlags.BypassRules);
Project pro = wis.Projects["ProjectName"];
WorkItemTypeCollection wits = pro.WorkItemTypes;
WorkItem wi = new WorkItem(wits["Epic"]);
wi.Fields["System.Title"].Value = "Title";
wi.Fields["System.CreatedDate"].Value = Convert.ToDateTime("2016-09-01");
wi.Save();
}
Note: To use this, you must be the member of "Project Collection Administrators" security group.
Refer to this link for details: TFS API Part 48 – WorkItemControl And Bypass Work Item Rules.
Related
During working with TFS API, I faced the following problem.
I have two repository changesets, say A and B:
In changeset A the file 1.cs was changed
In changeset B the file 1.cs was renamed
Is there a way to find out that files with different names from changeset A and B are in fact the same file that was renamed? I thought I could use ItemId from Item properties list but for some reason its different.
Here is some sample, which demonstrates the issue:
var changeset = versionControl.GetChangeset(changesetA);
var changeItemA = changeset.Changes.Single(i => i.Item.ServerItem == "1.cs");
var changeset = versionControl.GetChangeset(changesetB);
var changeItemB = changeset.Changes.Single(i => i.Item.ServerItem == "1.cs");
// fails
Assert.Equal(changeItemA.Item.ItemId, changeItemB.Item.ItemId);
I use Microsoft.TeamFoundationServer.Client version="14.102.0" and Microsoft.TeamFoundationServer.ExtendedClient version="14.102.0" to interact with TFS (.Net 4.6.2)
Is there a unique identifier that is assigned to TFS item and that lives with it during the whole life regardless of renaming?
We work with TFS 2013 and every month we create a new iteration (vx.x.x.x etc). Every iteration has a standard set of Userstory's / tasks that need to be done to complete the iteration. Currently we need to create these workitems every month with the same data in them. Is there a way to automate this process? I was thinking about "Default work items" for an iteration, is that possible in TFS 2013?
Thanks in advance,
Tim
I don't think you can do it without writing some code. I suggest using TFS API and create some kind of tool which will create new iteration and required work items. E.g.
var tpc = new TfsTeamProjectCollection(new Uri("collection url, e.g. http://localhost:8080/tfs/DefaultCollection"));
var css = tpc.GetService<ICommonStructureService4>();
var store = tpc.GetService<WorkItemStore>();
var server = tpc.GetService<WorkItemServer>();
var project = store.Projects["MyProject"];
/*get root iteration node*/
NodeInfo rootIteration = css.ListStructures(project.Uri.ToString()).First(n => n.StructureType == "ProjectLifecycle");
/*create new iteration*/
css.CreateNode("TestIteration", rootIteration.Uri.ToString());
/*sync changes*/
server.SyncExternalStructures(WorkItemServer.NewRequestId(), project.Uri.ToString());
project.Store.RefreshCache();
/*create new bug in the new iteration*/
var bug = project.WorkItemTypes["Bug"].NewWorkItem();
bug.Title = "Test";
bug.AreaPath = "MyProject\\TestIteration";
bug.Save();
Is there a way to programmatically access the "Kanban Column" for a WorkItem using the TFS 2012 API?
Using the Scrum 2.2 template, the history of a Bug or Product Backlog Item shows "[MyProject\MyTeam] Kanban Column" as a changed field whenever a work item is dragged between Kanban columns on the Board, but the field is not accessible when specifically retrieving a work item through the TFS API.
It also shows up as a changed field in the WorkItemChangedEvent object when implementing the ProcessEvent method on the Microsoft.TeamFoundation.Framework.Server.ISubscriber interface.
Workaround:
A coworker found a blogpost about creating a read-only custom field to persist the value of the Kanban Column, taking advantage of the WorkItemChangedEvent to capture the latest value. It is then possible to query on this column. One problem with this approach is that only a single team's Kanban Column can be tracked.
Update:
According to this blogpost, the Kanban Column is not a field, rather a "WIT Extension". This may help lead to an answer.
I've found a way to read the value using the TFS 2013 API, inside the ISubscriber.ProcessEvent method:
var workItemId = 12345;
var extService = new WorkItemTypeExtensionService();
var workItemService = new WorkItemService();
var wit = workItemService.GetWorkItem(requestContext, workItemId);
foreach (var wef in extService.GetExtensions(requestContext, wit.WorkItemTypeExtensionIds))
{
foreach (var field in wef.Fields)
{
if (field.LocalName == "Kanban Column" || field.LocalName == "Backlog items Column")
{
// Access the new column name
var columnName = wit.LatestData[field.Field.FieldId];
}
}
}
If you are prepared to dig into the database you can mine this information out. I don't fully understand the modelling of the teams in TFS yet but first you need to work out which field id the team of interest is storing the Kanban state in as follows (TFS 2012):
USE Tfs_DefaultCollection
SELECT TOP(10)
MarkerField + 1 as FieldId,*
FROM tbl_WorkItemTypeExtensions with(nolock)
JOIN tbl_projects on tbl_WorkItemTypeExtensions.ProjectId = tbl_projects.project_id
WHERE tbl_projects.project_name LIKE '%ProjectName%
Then replace XXXXXXXX below with the FieldId discovered above
SELECT TOP 1000
wid.Id,
wia.State,
wid.StringValue as Kanban,
wia.[Work Item Type],
wia.Title,
tn.Name as Iteration
FROM tbl_WorkItemData wid with(nolock)
JOIN WorkItemsAre wia on wia.ID = wid.Id
JOIN TreeNodes tn on wia.IterationID = tn.ID
WHERE FieldId = XXXXXXXX and RevisedDate = '9999-01-01 00:00:00.000'
ORDER BY Id
I am not familiar with the Scrum 2.2 template, but the works are the same for CMMI or Scrum templates when it comes to TFS Work Item tracking.
Try something like this:
public string GetKanbanColumn(WorkItem wi)
{
if (wi != null)
{
return wi["Kanban"].ToString();
}
return string.Empty;
}
Depending on the actual name of the column, specified in the Work Item Template XML file. Hope this helps.
We have a Team Project Collection Source Control Setting for Check-in Notes that requires each check-in to capture a "Tracking Number". This number is external to TFS. I need to search for all the changesets that have a specific Tracking number.
The resulting changeset list tells me what to GetLatest on, for our monthly deployment.
-- We don't use Work Items
This .SQL gives me the list I'm looking for. I want to access this in code from Visual Studio.
SELECT ReleaseNoteId, FieldName, BaseValue
from Tfs_DefaultCollection.dbo.tbl_ReleaseNoteDetails
where ReleaseNoteId in (SELECT ReleaseNoteId
FROM Tfs_DefaultCollection.dbo.tbl_ReleaseNote
where DateCreated between '2013-01-01' and '2013-01-31')
and FieldName = 'Tracker #'
and BaseValue = '18570'
What object references are available for Tfs_DefaultCollection.dbo.tbl_ReleaseNoteDetails?
There is no 1to1 object reference in the TFS API, because you usually don't work on the structure like the database looks like.
What I understand from your description, you have the information you need in the changesets. In that case you could use the VersionControlServer to get the changesets and get the information from there.
TfsTeamProjectCollection tfsConnection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFS:8080/TFS/DefaultCollection"));
VersionControlServer sourceControl = (VersionControlServer)tfsConnection.GetService(typeof(VersionControlServer));
IEnumerable changesets = sourceControl.QueryHistory(ServerPath, VersionSpec.Latest, 0, RecursionType.Full, null, new DateVersionSpec (new DateTime(2013,1,1)), new DateVersionSpec (new DateTime(2013,1,31)), Int32.MaxValue, true, false);
foreach (Changeset change in changesets)
{
// check where the information is stored in the changeset, may change.Changes
}
Just an idea to get in the right direction.
If you want easy querying and searching, you're better off creating a new work item field and associate the work item during checkin. Work items have complete querying capabilities in the UI and are even transported to the Reporting warehouse.
You could retrieve the history for a specific folder, date range etc using a QueryHistoryParameters object and then iterate over the CheckinNotes to filter:
var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
new Uri("http://localhost:8080/tfs/DefaultCollection"));
var versionControlServer = projectCollection.GetService<VersionControlServer>();
var query = new QueryHistoryParameters("$/Scrum/**", RecursionType.Full);
var changesets = server.QueryHistory(query);
changesets.Where(cs => cs.CheckinNotes.Any(note => note.PropertyName == "Tracker #"
&& note.Value == "18570"))
This is not going to be terribly fast. To get a quick solution, use work item association.
We are running one MOSS application as below:-
1. user use InfoPath request form to trigger workflow attached to SharePoint document library
2. all sub-sequent tasks are performed by users by InfoPath task form within SharePoint site through "Workflow Task" list (open, checkout, approve or reject) till the task completed.
3. all request form submitted could be viewed as xml file in the document library through "Explorer View"
My quesiton is why I cannot update the item located in the document library, basically open the SPListItem:-
SPSite thisSite = new SPSite("http://server")
{
SPWeb thisWeb = thisSite.OpenWeb("/web")
{
thisSite.AllowUnsafeUpdates = true;
thisWeb.AllowUnsafeUpdates = true;
SPDocumentLibrary library = (SPDocumentLibrary)thisWeb.Lists["DocLib"];
foreach (SPListItem item in library.Items)
{
SPFile file = item.File;
I tried almost all ways I could find:-
item["Customer Name"] = "123456";
item.Update();
// or item.SystemUpdate();
file.Item["Customer Name"] = "123456";
file.Update();
After each update, the value resumed when reopen or visit through the same code lines!
but when I view item properties, the "Last modified" is changed
Last modified at 6/8/2010 12:27 AM by Administrator
This do drive me cray, any help, please.
Thanks & best regards,
Leon
When you publish your form to a list, it asks you to choose the fields to be shown on that list. As you choose the item you want to update, click "Modify". Check the checkbox
at the bottom saying "Allow user to edit data in this field by using a datasheet or property page". This works for me.