Inherit Team from parent to all its children
🚧 If you try to assign two or more Team to a Bug, Task or User Story and Team Workflow is not configured, you will see an error in rule's log
Created TeamAssignment#2175 (13829892-8d76-4de1-a125-cc37a7cbccd1)
12/26/2018, 5:40:10 PM
JavaScriptAction -> CreateEntityResult: (EntityType: TeamAssignment)
Unable to create TeamAssignment: You can assign multiple teams to Bugs only when each team uses their own Team Workflow.
Assign the User Story's Team to all its Bugs
📘 User Story's Team is already automatically assigned to all its Tasks. This is a build-in behavior which cannot be changed or configured.
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"TeamAssignment"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"Team"
]
}
},
{
"or": [
{
"and": [
{
"target": {
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "EntityType",
"target": {
"type": "field",
"name": "Assignable",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"value": {
"type": "constant",
"value": "UserStory"
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const teamId = args.Current.Team.Id;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst bugs = await api.queryAsync(\"Bug\", {\n select: \"id\",\n where: \"userstory.id = \" + args.Current.Assignable.Id +\n \" and assignedTeams.Count(team.id = \" + teamId + \") = 0\"\n});\n\nreturn bugs.map(id => {\n return {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"TeamAssignment\",\n fields: {\n Team: { Id: teamId },\n Assignable: { Id: id }\n }\n }\n }\n});"
}
]
Assign the Feature's Team to all its Bugs and User Stories
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"TeamAssignment"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"Team"
]
}
},
{
"or": [
{
"and": [
{
"value": {
"type": "constant",
"value": "Feature"
},
"target": {
"name": "Name",
"type": "field",
"target": {
"name": "EntityType",
"type": "field",
"target": {
"name": "Assignable",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const teamId = args.Current.Team.Id;\nconst select = collection => `${collection}.Where(assignedTeams.Count(team.id = ${teamId}) = 0).Select(id)`;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst features = await api.queryAsync(\"Feature\", {\n select: `{ stories: ${select(\"UserStories\")}, bugs: ${select(\"Bugs\")} }`,\n where: \"id = \" + args.Current.Assignable.Id\n});\nif (!features.length) { return; }\n\nconst children = [...features[0].stories, ...features[0].bugs];\n\nreturn children.map(id => {\n return {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"TeamAssignment\",\n fields: {\n Team: { Id: teamId },\n Assignable: { Id: id }\n }\n }\n }\n});"
}
]
Assign the Epic's Team to all its Features
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"TeamAssignment"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"Team"
]
}
},
{
"or": [
{
"and": [
{
"value": {
"type": "constant",
"value": "Epic"
},
"target": {
"name": "Name",
"type": "field",
"target": {
"name": "EntityType",
"type": "field",
"target": {
"name": "Assignable",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const teamId = args.Current.Team.Id;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst features = await api.queryAsync(\"Feature\", {\n select: \"id\",\n where: \"epic.id = \" + args.Current.Assignable.Id +\n \" and assignedTeams.Count(team.id = \" + teamId + \") = 0\"\n});\n\nreturn features.map(id => {\n return {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"TeamAssignment\",\n fields: {\n Team: { Id: teamId },\n Assignable: { Id: id }\n }\n }\n }\n});"
}
]
Assign the Portfolio Epic's Team to all its Features and Epic
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"TeamAssignment"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"Team"
]
}
},
{
"or": [
{
"and": [
{
"value": {
"type": "constant",
"value": "PortfolioEpic"
},
"target": {
"name": "Name",
"type": "field",
"target": {
"name": "EntityType",
"type": "field",
"target": {
"name": "Assignable",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const teamId = args.Current.Team.Id;\nconst select = collection => `${collection}.Where(assignedTeams.Count(team.id = ${teamId}) = 0).Select(id)`;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst portfolioEpics = await api.queryAsync(\"PortfolioEpic\", {\n select: `{ features: ${select(\"Features\")}, epics: ${select(\"Epics\")} }`,\n where: \"id = \" + args.Current.Assignable.Id\n});\nif (!portfolioEpics.length) { return; }\n\nconst children = [...portfolioEpics[0].features, ...portfolioEpics[0].epics];\n\nreturn children.map(id => {\n return {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"TeamAssignment\",\n fields: {\n Team: { Id: teamId },\n Assignable: { Id: id }\n }\n }\n }\n});"
}
]