0

I try to create a WIQL query that compares field contents of a work item and its related (linked) work items, e.g. where the 'state' of the work item is different from the 'state' of the related work item.

SELECT [System.Id], ... FROM WorkItemLinks WHERE ...
[Source].[System.State] <> [Target].[System.State])
ORDER BY [System.CreatedDate] desc, [System.AssignedTo] mode(MayContain)

(The ... above only indicate the parts that I have ommitted here for clarity.)

When I try to apply the query, I get this error message from TFS:

The link query can not mix expression with different prefixes

Is there a way to compare source and target fields with WIQL?

Heinz Kessler
  • 1,610
  • 11
  • 24

1 Answers1

0

No, just as the error message indicates, you cannot mix expression with different prefixes. So you cannot compare the field in Source and Target directly. Refer to this link from MSDN for details: http://blogs.msdn.com/b/team_foundation/archive/2010/07/02/wiql-syntax-for-link-query.aspx

However, for the fields with pre-defined list values, you can write the query like following to achieve the feature you want.

SELECT [System.Id] FROM WorkItemLinks WHERE 
([Source].[System.State] = ‘New’ and [Target].[System.State] <> ‘New’) 
OR ([Source].[System.State] = ‘Resolved’ and [Target].[System.State] <> ‘Resolved’)
OR ([Source].[System.State] = ‘Active’ and [Target].[System.State] <> ‘Active’)
OR ([Source].[System.State] = ‘Closed’ and [Target].[System.State] <> ‘Closed’)
ORDER BY [System.CreatedDate] desc, [System.AssignedTo] mode(MayContain)
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60