How to query Milestones by Artifacts and Artifacts by Milestones

Document ID : KB000057522
Last Modified Date : 14/02/2018
Show Technical Document Details

Issue

Artifacts collection on a Milestone and Milestones collection on Artifact?

Resolution

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:

In this example we have a defect that is scheduled for a milestone.
To illustrate their relationship we first query a defect by FormattedID and fetch either full object or Milestones attribute specifically.
Notice that this is not a one-to-one relationship but a one-to-many: Milestones attribute on an Artifact is a reference to a collection:

User-added image

Here is an endpoint equivalent of this query that fetches Milestones attribute only:
https://rally1.rallydev.com/slm/webservice/v2.0/defect?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/29047390143&query=(FormattedID = DE11)&fetch=Milestones

Note that _tagsNameArray is not a part of the schema and should not be relied in custom code.

Here is a query example that shows how to query Artifacts by Milestones:

(Milestones contains /milestone/33075243698)

User-added image


Here is an endpoint equivalent of this query:

https://rally1.rallydev.com/slm/webservice/v2.0/defect?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/29047390143&query=(Milestones contains /milestone/33075243698)&fetch=true&pagesize=200

Note that unlike Tags where (Tags.Name contains "myTag") returns expected results,?(Milestones.Name contains "myDefect")? does not return results and should not be relied on.

https://rally1.rallydev.com/slm/webservice/v2.0/defect?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/29047390143&query=(Milestones.Name contains ".NET Toolkit")

User-added image

2. Query a Milestone by Artifact:

Here is a query example that shows how to query Milestones by Artifacts:
(Artifacts contains /defect/30805339204)

User-added image


Here is an endpoint equivalent of this query:
https://rally1.rallydev.com/slm/webservice/v2.0/milestone?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/29047390143&query=(Artifacts contains /defect/30805339204)&pagesize=200


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

?