Lookback API _ProjectHierarchy not scoping down

拈花ヽ惹草 提交于 2019-12-12 02:24:33

问题


Hi I am fetching the current userstories for a particular iteration using the following code

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',

    launch:function(){
        me = this;
        combo = window.parent.Ext4.ComponentQuery.query('rallyiterationcombobox')[0];
        var iterationObjectID = combo.getRecord().data.ObjectID;
        var query1= { _ProjectHierarchy: me.getContext().getProject().ObjectID, Iteration : iterationObjectID , _TypeHierarchy:"HierarchicalRequirement"};
        var fields = ["ObjectID","FormattedID","Name","Parent","Release","Tags","PlanEstimate","ScheduleState","_ValidFrom","_ValidTo"];
        var hydrate = ["Tags","ScheduleState"];
        var post = { find :query1, fields : fields, hydrate : hydrate, pagesize : 10000 };
        var wsid = this.context.getWorkspace().ObjectID;
        var url = "https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/"+ wsid +"/artifact/snapshot/query.js";
        console.log("snapshot url:",url);


            Ext.Ajax.request({
                method: 'POST',
                url: url,
                jsonData : post,
                success: function(res) {
                    res = JSON.parse(res.responseText);
                    console.log("The final results are",res);


                },

                failure: function(failure) {
                    console.log("snapshot query failed!",failure);
                }
            });

The problem is that I could not get the user stories of the child projects when I specify the parent project in the query. For example if I have the hierarchy like this

Project 7890
     User Story 55
     User Story 56
        Project 6543
         User Story 57
           Project 3456
              User Story 777

Ideally If I query _ProjectHierarchy: 7890 I should be getting User Story 55,User Story 56,User Story 57,User Story 777 since the query retrieves the multiple work items of itself and its child projects,but here I am only able to get User Story 55,User Story 66(which are userstories of project 7890) but not User Story 57,User Story 777 since those are the User Stories of the child projects. I want to retrieve all User Stories of selected project and its child projects also(i.e scope down).


回答1:


Check out the LBAPI Docs for some good info on this, particularly the difference between _ProjectHierarchy and _ItemHierarchy/_TypeHierarchy.

In your situation, you should probably be using the _ItemHierarchy/_TypeHierarchy:

Work item hierarchy

The work item hierarchy traverses a Parent/Child relationship using the _ItemHierarchy field. So if you have this hierarchy:

  Story 333
     Story 444
        Story 555
           Story 666
              Defect 777
                 Task 12
              Task 13
        Story 888
        Story 999

The document for Story 666 would look like this:

  {
     ObjectID: 666,
     Parent: 555,
     _ItemHierarchy: [333, 444, 555, 666],
     ...
  }

To retrieve all Stories that descend from Story 333 (includes 333, 444, 555, 666, 888, and 999 but not Defect 777), you would include this clause in your query:

  {
     _ItemHierarchy: 333,
     _TypeHierarchy: “HierarchicalRequirement”
  }

Project hierarchy

The Project hierarchy is also represented as an array starting at a root Project for this Workspace. So if work item 777 is at the bottom of this Project hierarchy:

 Project 7890
    Project 6543
       Project 3456
          Work item 777

The document for work item 777 would look like this:

 {
     ObjectID: 777,
     Project: 3456,
     _ProjectHierarchy: [7890, 6543, 3456],
     ...
 }

To retrieve multiple work items that are in Project 7890 or any of its child projects, you would simply include this clause in your query:

_ProjectHierarchy: 7890


来源:https://stackoverflow.com/questions/15556923/lookback-api-projecthierarchy-not-scoping-down

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!