views:

358

answers:

2

I need to create a macro or VS.net Addin that will insert the current date and time and user name in a field in a TFS work item.

The sample macro does not work and I cannot find any way to programaticaly access a TFS work item that is open in the IDE.

Is this possible?

A: 

AFAIK, no this is not possible. It is possible to work with the same WorkItem that is open in the IDE. This can be done by connecting to the WorkItemStore instance and opening the same item.

However I do not believe it's possible to access the WorkItem instance that is open in the IDE. That would require the TFS Client to expose a service from which you could query the active WorkItem. I do not believe they do so.

JaredPar
A: 

This might be possible if you write your own custom WIT controls. Even then, I'm not sure it would be accessible from a macro -- might have to write a VS add-in as well.

Nevertheless, it sounds like whatever you're doing would be better served by the built-in TFS workflow engine. Let's say you want to record the current date & current user whenever someone resolves a bug. All you have to do is override the XML definition for the transition between the two states. For example:

<Transition from="Not Done" to="Ready For Test">
  <ACTIONS>
    <ACTION value="Microsoft.VSTS.Actions.Checkin" />
  </ACTIONS>
  <REASONS>
    <DEFAULTREASON value="Sent to QA" />
  </REASONS>
  <FIELDS>
    <FIELD refname="Microsoft.VSTS.Common.ResolvedBy">
      <COPY from="currentuser" />
      <VALIDUSER />
      <REQUIRED />
    </FIELD>
    <FIELD refname="Microsoft.VSTS.Common.ResolvedDate">
      <SERVERDEFAULT from="clock" />
    </FIELD>
  </FIELDS>
</Transition>

If that's not enough, here's a 14-part (!) series on WIT customization: http://blogs.msdn.com/eugenez/archive/2009/05/10/work-item-customization-tidbits-custom-controls-part-14-of-x.aspx

Richard Berg