由团队成员查询任务

时间:2012-01-13 13:59:27

标签: javascript rally

我是否可以修改此查询字符串以过滤搜索结果,只搜索所有者是当前项目的团队成员的任务?

这是我到目前为止的查询,它除了团队成员声明

之外还有效
queryObject = { key: "tasks", type: "Task", fetch: "FormattedID,Owner,DisplayName,Name,State,Estimate,ToDo,Iteration,Name", query: ' (((State = "Completed") AND (Iteration = ' + selectedItr + ')) AND (Project.TeamMembers contains Owner))' };

1 个答案:

答案 0 :(得分:0)

很遗憾,您无法在一个查询中获取所有数据。您可以先让您的团队成员,然后构建一个包含所有引用的ORed查询,并对其任务执行第二次查询:

var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__', 
                                              '__PROJECT_OID__',
                                               '__PROJECT_SCOPING_UP__', 
                                              '__PROJECT_SCOPING_DOWN__'); 

var teamMembersQuery = { key: "teamMembers", type: "User", 
    fetch: "UserName", query: '(TeamMemberships = /project/__PROJECT_OID__)'};

rallyDataSource.findAll(teamMembersQuery, function(results) {
    var ownerQueries = [];
    rally.forEach(results.teamMembers, function(teamMember) {
        ownerQueries.push('Owner = ' + teamMember._ref);
    });

    var taskQuery = {key: "tasks", type: "Task", 
        fetch: "FormattedID,Owner,DisplayName,Name,State,Estimate,ToDo,Iteration,Name", 
        query: rally.sdk.util.Query.and(['State = "Completed"', 'Iteration = ' +
        selectedItr]).and(rally.sdk.util.Query.or(ownerQueries)) };

   rallyDataSource.findAll(taskQuery, function(results) {
       //process results.tasks here
   });

});

有关编写高级查询的更多示例,请参阅App SDK的RallyDataSource帮助: http://developer.rallydev.com/help/data-examples