Query tasks by team members
-
28-10-2019 - |
문제
Can I modify this query string to filter a search resulting with only tasks who's owners are team members of the current project?
This is the query I have so far which is working besides the team members statement
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))' };
해결책
Unfortunately you can't get all the data in one query. You can get your team members first and then build an ORed query with all of their refs to and do a second query for their tasks:
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
});
});
For more examples of writing advanced queries see the App SDK's RallyDataSource help: http://developer.rallydev.com/help/data-examples
제휴하지 않습니다 StackOverflow