How to query for object that do not have a particular child object
search cancel

How to query for object that do not have a particular child object

book

Article ID: 260691

calendar_today

Updated On:

Products

Rally SaaS Rally On-Premise Rally Perpetual Hosted

Issue/Introduction

At times it is necessary to WSAPI to retrieve items that are missing certain types of child objects.  For example, perhaps you are looking for all defects that don't have any attachments or all user stories that are not assigned to a release.  This article describes a pattern for performing this type of query.

Resolution

In general, if you're looking for items that don't have a child, you'll query for null ObjectIDs of that child type.

Using the examples above, in order to find work items that don't have any attachments, you would use a query as follows:

(Attachments.ObjectID = null)

Or, if you are looking for work items that aren't assigned to a release, you will use a query as shown below:

(Release.ObjectID = null)

 

The pattern will generally follow the child/sub object name as laid out in the object model and will use the ObjectID attribute.

The reverse is true if you wish to find items that are explicitly populated, so only work items with those child associations would be as follows for example:

(Attachments.ObjectID != null)

(Release.ObjectID != null)