Linking work item when checking in (AX2012)

Dynamics AX 2009 supports Team Foundation Server for storing source codes, but it doesn’t offer (out of the box) any option how to create a link between the changeset being created and a work item. Because such a relation is extremely useful and it is too complicated and error-prone to create it manually, I made a solution for AX2009 in a form of AX TFS WorkItems. But what’s the situation in Dynamics AX 2012?

Fortunately, Microsoft implemented some sort of solution in AX2012 – it’s minimalist but still quite functional.

Check in dialog has now a Work items tab, where work items can be selected for linking to the changeset. It’s also possible to choose an action in Check-in action field – for example to declare a task as resolved, which changes the state of the appropriate Task work item in TFS to Closed. (Specific behaviour depends on the process definition in TFS.)

Check-in - záložka Work items

The dialog automatically shows work items assigned to the current user (within the team project defined in Version control parameters). Additional work items can be added by entering a Work Item ID to the field above the grid and pressing Add work item.

After that, you just need to check Include for one or more items, change Check-in action if desired and confirm that by the OK button.

I expect that the default list of displayed items won’t be fully suitable for most teams. Especially because it shows even closed items, but maybe you also don’t want to see all work item types or you want to restrict the query just to items in the current iteration.

Fortunately, such a modification is very easy. The list of work items is acquired by a Work Item Query Language (WIQL) query, which is saved in a macro in ClassDeclaration of SysVersionControlWorkItemProviderTFS class. It looks like this:

SELECT [System.Id], [System.Title] FROM WorkItems
    WHERE [System.TeamProject] = @project
    AND [System.AssignedTo] = @me
    ORDER BY [System.Id]

After adding some conditions limiting the result to active tasks only, the query would look as follows:

SELECT [System.Id], [System.Title] FROM WorkItems
    WHERE [System.TeamProject] = @project
    AND [System.AssignedTo] = @me
    AND [System.WorkItemType] = 'Task'
    AND [System.State] = 'Active'
    ORDER BY [System.Id]

If you need to display more fields (e.g. work item type or state), it cannot be achieved so easily. It’s because Check-in dialog uses a temporary table (SysVersionControlTmpWorkItems), so the list of available fields is fixed. Sure, it’s possible to add some additional fields to the table and secure their filling, but that is not so simple task as the modification of filtering.

Plans with AX TFS WorkItems

AX TFS WorkItems has several features missing in AX2012 – particularly the possibility to run WIQL queries saved in TFS and the ability to display variable number of fields (according to the query definition). Nevertheless, I don’t consider that as an essential functionality and I don’t plan – at least for now – to implement it in Dynamics AX 2012.

2 Comments

  1. Hi Martin
    Can you help me with any document or article through which we can totally automate the build and deployment process in Ax2012 through TFS. There are some powershell scripts given for this purpose but how to create the workflow, build definition etc in TFS, that I couldn’t get anywhere.

    Also when how can we merge using the workitems not the changeset number because a workitem might be consisting of many changeset number and in TFS i suppose one doesn’t get the option to merge on the basis of workitem.

    Looking forward for your reply.

    • I suggest you ask on community.dynamics.com. I will answer it there and maybe Joris or somebody else will join the discussion.
      It’s not very discoverable here.

Comments are closed.