Mention Assigned Users on Status Change
Mention Developers and PMs when a Feature changes its state (main state)
This rule will be triggered when Feature changes it's Project state (main state)
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"feature"
],
"modifications": {
"created": false,
"deleted": false,
"updated": [
"EntityState"
]
}
},
{
"type": "action:JavaScript",
"script": "const roles = [\"Developer\", \"PM\"];\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst users = await api.queryAsync(\"Assignment\", {\n select: \"{generaluser.login,generaluser.firstname,generaluser.lastname}\",\n where: `assignable.id=${args.ResourceId} and Role.Name in ${JSON.stringify(roles)}`\n});\nif (!users || !users.length) { return; }\n\nconst mention = users.map(user => {\n return `@user:${user.login}[${user.firstname} ${user.lastname}]`\n}).join(\",\");\n\nreturn {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"Comment\",\n fields: {\n General: { Id: args.ResourceId },\n Description: mention + \", this item changed its state to \" + args.Current.EntityState.Name\n }\n }\n};"
}
]
Mention Developers and PMs when a Feature changes its state (sub state)
This rule will be triggered when Feature changes it's Team state (sub state)
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"teamassignment"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"EntityState"
]
}
},
{
"type": "filter:Relational",
"or": [
{
"and": [
{
"target": {
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "EntityType",
"target": {
"type": "field",
"name": "Assignable",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"value": {
"type": "constant",
"value": "Feature"
},
"operator": {
"type": "is"
}
}
]
}
]
},
{
"type": "action:JavaScript",
"script": "const roles = [\"Developer\", \"PM\"];\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst users = await api.queryAsync(\"Assignment\", {\n select: \"{generaluser.login,generaluser.firstname,generaluser.lastname}\",\n where: `assignable.id=${args.Current.Assignable.Id} and Role.Name in ${JSON.stringify(roles)}`\n});\nif (!users || !users.length) { return; }\n\nconst mention = users.map(user => {\n return `@user:${user.login}[${user.firstname} ${user.lastname}]`\n}).join(\",\");\n\nreturn {\n command: \"targetprocess:CreateResource\",\n payload: {\n resourceType: \"Comment\",\n fields: {\n General: { Id: args.Current.Assignable.Id },\n Description: mention + \", this item changed its state to \" + args.Current.EntityState.Name\n }\n }\n};"
}
]
Updated over 4 years ago