It's all about the answers!

Ask a question

How to from either command line or the rest API to traverse and found all parents of a work item


nannette Mori (50141) | asked Aug 21 '15, 11:50 a.m.

I need to find all parents of a work item.  How can I accomplish this using either command line or the rest API

Thank You!

2 answers



permanent link
Ralph Schoon (58.7k23642) | answered Aug 21 '15, 4:16 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
There can only be one parent. See https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/

Comments
nannette Mori commented Aug 21 '15, 4:32 p.m.

I guess I was not clear I need to traverse the tree of parents

example:  I have a story, from the story I want to know what the Feature is, and from the feature I want to know what the epic was


permanent link
Donald Nong (14.4k314) | answered Aug 23 '15, 11:38 p.m.
edited Aug 23 '15, 11:40 p.m.
If you are using OSLC API, namely, accessing the work item via the URL such as /ccm/resource/itemName/com.ibm.team.workitem.WorkItem/114, you can find the parent work item in two places within the response body.
1. In the <Description> itself.
    <rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.parent rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/43" />
2. In a separete "node".
      <rdf:Description rdf:nodeID="A4">
        <rdf:subject rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/114"/>
        <rdf:predicate rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/com.ibm.team.workitem.linktype.parentworkitem.parent"/>
        <rdf:object rdf:resource="https://clm:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/43"/>
        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"/>
        <dcterms:title>43: Implement - Requests sent in form of email</dcterms:title>
      </rdf:Description>

If you are using the reportable REST API, you can query the parent directly using the URL such as
     /ccm/rpt/repository/workitem?fields=workitem/workItem[id=114]/parent/*.
You can even get the grandparent, great-grandparent in the same query if you so desire
     /ccm/rpt/repository/workitem?fields=workitem/workItem[id=114]/(id|summary|parent/(id|summary|parent/(id|summary|parent/(id|summary)))).

Your answer


Register or to post your answer.