How to query Milestones by Artifacts and Artifacts by Milestones

Document ID : KB000057522
Last Modified Date : 06/08/2018
Show Technical Document Details
Question:
How does one query a Milestone by Artifact, or query for Artifacts by Milestone? 

For instance, if a user would like to get a list of work items such as user stories or defects associated to a certain milestone via a query, how is that done? 

 

Answer:
Per WS API object model, there is Artifacts collection on a Milestone and Milestones collection on Artifact, allowing many-to-many relationships.
  1. Query an Artifact by Milestone
  2. Query a Milestone by Artifact


1. Query an Artifact by Milestone:

One can query a work item by simply specifying the Formatted ID of the Milestone:

(Milestones.FormattedID = "MI9")

User-added image

2. Query a Milestone by Artifact:

For an Artifact that is associated to a Milestone, such as US640 in the below screenshot:
User-added image

Simply query the Milestone's Artifacts collection by using the syntax: (Artifacts.FormattedID = "US1") :
User-added image

Related article:
How to query Milestones and their RevisionHistory by Project in WS API