Web Services API: How to query for defects that are not associated to any user story

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

Issue

How to query for defects that are not associated to any user story. In UI on the defect's details page there is a "User Story" field but if (UserStory != null)? query in a custom grid returns error:
Could not parse: Could not find attribute "UserStory" on type Defect in the query segment "UserStory"

Resolution

Use "Requirement" attribute on the defect object in WS API.
https://rally1.rallydev.com/slm/doc/webservice/objectModel.sp#Defect

1. CUSTOM GRID:

In a custom grid (Requirement = null) will return up to 200 defects not associated with user stories, and (Requirement != null) will return up to 200 defects associated with user stories.

User-added image

2. CUSTOM JAVASCRIPT APP:


See an example in this github repo for an app that displays user stories associated with defects It uses a renderer function to display a link to story to which a defect is linked or "None" if a defect is not associated to a story.

{text: 'Requirement', dataIndex: 'Requirement',
? ? ? ? ? ? ? ? ? ? renderer: function(val, meta, record) {
? ? ? ? ? ? ? ? ? ? ? ? if(record.get('Requirement')){
? ? ? ? ? ? ? ? ? ? ? ? ? ? return '<a href="https://rally1.rallydev.com/#/' + record.get('Requirement').
Project.ObjectID + '/detail/userstory/' + record.get('Requirement').ObjectID + '" target="_blank">' + record.get('Requirement').FormattedID + '</a>';
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? else{
? ? ? ? ? ? ? ? ? ? ? ? ? ? return 'None'
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }


The app is written with AppSDK2 . It is provided only as an illustration of what's possible. It is not in App Catalog and is not formally supported by Rally.