Assign a User Story's Feature to a Bug
This use case consists of two rules
When a Bug is assigned to a User Story, inherit User Story's Feature
The filter by Project.Name
is optional.
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"Bug"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"UserStory"
]
}
},
{
"or": [
{
"and": [
{
"value": {
"type": "constant",
"value": "Pilot"
},
"target": {
"name": "Name",
"type": "field",
"target": {
"name": "Project",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:targetprocess:UpdateEntity",
"fields": {
"Feature": {
"name": "Feature",
"type": "field",
"target": {
"name": "UserStory",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"target": {
"type": "pipelineBlockOutput",
"blockAlias": "ui:source"
}
}
]
When User Story's Feature was changed, change Feature for all its Bugs
User Story should have not more than 50 of Bugs in it.
The filter by Project.Name
is optional.
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"UserStory"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"Feature"
]
}
},
{
"or": [
{
"and": [
{
"value": {
"type": "constant",
"value": "Pilot"
},
"target": {
"name": "Name",
"type": "field",
"target": {
"name": "Project",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const api = context.getService(\"targetprocess/api/v2\");\nconst bugs = await api.queryAsync(\"Bug\", {\n select: 'id',\n where: 'userStory.id=' + args.ResourceId\n});\n\nconst feature = args.Current.Feature ? { Id: args.Current.Feature.Id } : null;\n\nreturn bugs.map(id => {\n return {\n command: \"targetprocess:UpdateResource\",\n payload: {\n resourceType: \"Bug\",\n resourceId: id,\n fields: {\n Feature: feature\n }\n }\n };\n})\n"
}
]
Updated over 5 years ago