Assign a bug to a current Release/Team Iteration
Assign a new bug to a current Release
{
"pipeline": [
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"bug"
],
"modifications": {
"created": true,
"deleted": false,
"updated": false
}
},
{
"type": "filter:Relational",
"or": [
{
"and": [
{
"target": {
"type": "field",
"name": "Release",
"target": {
"type": "pipelineBlockOutput"
}
},
"value": null,
"operator": {
"type": "not exists"
}
}
]
}
]
},
{
"type": "action:JavaScript",
"script": "const project = args.Current.Project;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst releases = await api.queryAsync(\"Releases\", {\n select: \"id\",\n where: \"IsCurrent=true and Project.Id==\" + project.Id\n});\nif (!releases || !releases.length) {\n console.log(`There is no current Release for the Project #${project.Id} ${project.Name}`);\n return;\n};\n\nreturn {\n command: \"targetprocess:UpdateResource\",\n payload: {\n resourceType: args.ResourceType,\n resourceId: args.ResourceId,\n fields: {\n Release: { Id: releases[0] }\n }\n }\n};"
}
]
}
Assign a bug to a current Team Iteration (when a bug is assigned to the Team)
{
"pipeline": [
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"teamassignment"
],
"modifications": {
"created": true,
"deleted": false,
"updated": false
}
},
{
"or": [
{
"and": [
{
"target": {
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "EntityType",
"target": {
"type": "field",
"name": "Assignable",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"value": {
"type": "constant",
"value": "Bug"
},
"operator": {
"type": "is"
}
},
{
"target": {
"type": "field",
"name": "TeamIteration",
"target": {
"type": "field",
"name": "Assignable",
"target": {
"type": "pipelineBlockOutput"
}
}
},
"value": null,
"operator": {
"type": "not exists"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const team = args.Current.Team;\r\n\r\nconst api = context.getService(\"targetprocess/api/v2\");\r\nconst iterations = await api.queryAsync(\"TeamIteration\", {\r\n select: \"id\",\r\n where: \"IsCurrent=true and Team.id=\" + team.Id\r\n});\r\nif (!iterations || !iterations.length) {\r\n console.log(`There is no current Team Iteration for the Team #${team.Id} ${team.Name}`);\r\n return;\r\n};\r\n\r\nreturn {\r\n command: \"targetprocess:UpdateResource\",\r\n payload: {\r\n resourceType: args.Current.Assignable.ResourceType,\r\n resourceId: args.Current.Assignable.Id,\r\n fields: {\r\n TeamIteration: { Id: iterations[0] }\r\n }\r\n }\r\n};"
}
]
}
Updated over 2 years ago