Understanding Action for state transition in Details

In this blog series I will explain TFS Process Customization in details, I will try to explain what happen behind the scene, show common errors that happen when we perform customization and answer many questions that could come for anyone perform TFS Process Customization, this series consist of following parts:

Each part consist of one or many sections as needed.


Part 2 - Understanding Action for state transition in Details

Action is a very confused concept for many people, what is action? Can I create a custom action? How to use action or custom action?

So in this post I will try to simplify what is really meaning by Action and how does it work?

So the first question is: what is Action?

It’s just a unique string that used as a flag that added in the transition between states to be used by third party tools, so we can know which is the current state and which is the next state for given action in a work-item.

Just imagine that I have create a small application that has only one button that list some work-items from different types of work-items (Bug, Task, Change Request, Etc)

Change Sate based on action transation

I just want when I click on the button all work-items from Type-1 changed from Sate-1 to State-2 but if the work-items in State-2 or State-3, it remains in the same state.

I also need all work-items from Type-2 changed from Sate-2 to State-3 but if the work-items in State-1 or State-3,  it remains in the same state ……….. to do that I need to go to the WID (Work Item Definition) for these 2 types of work-items and in the transition between the desired states I will put my custom action, and this action can be retrieved by TFS SDK afterwards.

Work-item type 1

<TRANSITION from="State-1" to="State-2">


<ACTION value="Radwan.Actions.CustomAction">



Work-item type 2

<TRANSITION from="State-2" to="State-3">


<ACTION value="Radwan.Actions.CustomAction">



Work-item type 1
Work-item type 2

So when I get next state using TFS API or (SDK) with this custom action I can know which work-item in the desired state so I can advance it to the next state and if the work-item doesn’t has the action in the transition, that’s meaning I don’t need to advance its state.

The following code get some work-items and iterate over them and get next state for my custom action and print next state if it found that action.

WorkItemCollection witCollection = workItemStore.Query(wiqlQuery);
 foreach (WorkItem workItem in witCollection)

 Console.WriteLine("Next State for {0} is {1}", workItem.Title,


This will told me if my flag (Custom Action) is there or not and what is the next state so I can advance (change) the state.

class Program
 static void Main(string[] args)
 public static void RetrieveWorkItems()
 var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new
 var workItemStore = tfs.GetService<WorkItemStore>();

var wiqlQuery = String.Format(@"Select [State], [Title] From
 WorkItems Where [Work Item Type] = 'Task' Order By [State] Asc,
 [Changed Date] Desc"); ;

WorkItemCollection witCollection = workItemStore.Query(wiqlQuery);
 foreach (WorkItem workItem in witCollection)
 Console.WriteLine("ID: {0}", workItem.Id);
 Console.WriteLine("Title: {0}", workItem.Title);
 Console.WriteLine("Next State for {0} is {1}", workItem.Title, workItem.GetNextState("Microsoft.VSTS.Actions.Checkin"));
 Console.WriteLine("Next State for {0} is {1}", workItem.Title, workItem.GetNextState("Radwan.Actions.CustomAction"));

Automate field assignments based on State, Transition, or Reason
Work item Action list

Obtain possible next states of a work item programatically?

Changing State according to a field’s value

New State for TFS 2012

WorkItem.GetNextState Method


TF400618: The reporting type of field in work item type conflicts with the reporting type of the existing field.

When I upgrade a server from TFS 2010 to TFS2013 I faced the following error

There are no process templates available with valid configuration settings for this team project.

TF400618: The reporting type of field “Filed name” in work item type “Work-Item type” conflicts with the reporting type of the existing field.


This problem happen because the old project use a filed as reportable=”dimension”  but the new process template (Scrum 2013) doesn’t.

So all I need to do.

  1. Download the Scrum Process Template from TFS 2013
  2. Update the filed to be reportable=”dimension”
  3. Upload the process template and override the existing one

So now the 2 fileds are matching and it succeed

How to add an account to Service Accounts Group in TFS?

When I start working with TFS Integration Platform, I face the following error:

Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.PermissionException: TFS WIT bypass-rule submission is enabled. However, the migration service account 'Radwan' is not in the Service Accounts Group on server 
 at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsCore.CheckBypassRulePermission()
 at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsWITMigrationProvider.InitializeTfsClient()
 at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsWITMigrationProvider.InitializeClient()
 at Microsoft.TeamFoundation.Migration.Toolkit.MigrationEngine.Initialize(Int32 sessionRunId)

So how to add my account or the account that will be used to run TFS Integration Platform for the Service Accounts Group?

You can’t add accounts using the UI so we need to run a command line

From TFS Server as the following

C:\Program Files\Microsoft Team Foundation Server 12.0\tools>
\TFSSecurity.exe /g+ "Team Foundation Service Accounts"
n:domain\mradwan /server:http://vsalm

From Visual Studio client machine Server as the following

C:\Program Files\Microsoft Visual Studio Server 12.0\tools>
\TFSSecurity.exe /g+ "Team Foundation Service Accounts"
n:domain\mradwan /server:http://vsalm

Note: For sometimes you will have to type /server:http://vsalm:8080/tfs

Add account Service account group

Note: TFS Integration Platform 2012 can work with TFS 2013 but it needs the old object Model so just install Team Explorer 2012 or 2010 will solve the issue.

Do I need to remove Lab Management from a Collection when I Upgrade?

This is really a very important question, so the answer depends on some conditions, if you are upgrading to a different domain or if you will use a different SCVMM (System Center Virtual Machine Manager), you must delete the resources that are used by Lab Management from the collection database, this include virtual machines, templates, team project host groups, and team project library shares, otherwise you will keep them.

You will need to re-create the Lab Management assets after you finish the upgrade

To remove the Lab Management resources

You will use:

TFSConfig Lab /Delete /External

The following is the notification when you don’t delete them.

Note: this also applyed for moving collection to another server

Team Foundation Server could not tear down the deployment rig on environment in project. Delete the Visual Studio 2010 Team Foundation Build Agent associated with this environment manually using Team Foundation Server Administrator Console. Exception Details: TF30040: The database is not correctly configured. Contact your Team Foundation Server administrator.

Delete the Lab Management resources

Can’t keep cloned projects in both collections (original and cloned)

Sometimes you may want to clone your collection for many reason, we can use the following command:

C:\Program Files\Microsoft Team Foundation Server 12.0\
Tools>tfsconfig collection /attach /collectionName:ClonedFabrikam
collectionDB:vsalm\SQLExpress;TFS_FabrikamFiberCollection /clone

And remember: 

  • You will need to detach the collection first and make a copy of the DB
  • The /clone switch didn’t actually clone DB it just telling TFS Admin Console this is a cloned collection so please don’t start it :-)

Note 1:
It’s important to know that you can’t start the cloned collection until you delete the projects from the original or the cloned collection, so you can’t keep projects on both collection, otherwise you will face the following error:

TF253021:The following team project is duplicated in at least two team project collections:  The collection cannot start while the duplication exists. You must delete this project from all but one of the collections before the collection can be started. The project exists in the following collections: 


Note 2:

It’s Important to know that you must detach the collection otherwise it will not appear when you try to attach, you can make the backup without detach if you are making upgrade from old version like 2010 or 2008.

Note 3:

For not detached collection you can use TFSConfig with Recover option but this only for TFS2010 but don’t use it with TFS2012 or TFS2013 as it’s deprecated

Fore more information:

Video for New Features in TFS 2013.2 (Update 2) CTP 1

Brian Harry just announced 2 weeks ago about VS/TFS 2013.2 (Update 2) CTP1, I really wanted to get close for the new features and enhancement so I decide to install that update and share my experience for the installation and the new features.

There is knowing issue about that update so it took from me sometimes to install and record my video, remember it’s not a Go live support.

Here is the video