Start an item when time is added on it
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"Task",
"UserStory",
"Bug",
"Feature",
"Epic",
"PortfolioEpic"
],
"modifications": {
"created": false,
"deleted": false,
"updated": [
"TimeSpent"
]
}
},
{
"or": [
{
"and": [
{
"target": {
"type": "field",
"name": "StartDate",
"target": {
"type": "pipelineBlockOutput"
}
},
"value": {
"type": "constant",
"value": null
},
"operator": {
"type": "not exists"
}
},
{
"target": {
"type": "field",
"name": "TimeSpent",
"target": {
"type": "pipelineBlockOutput"
}
},
"value": {
"type": "constant",
"value": 0
},
"operator": {
"type": ">"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const type = args.Current.EntityType.Name;\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst processes = await api.queryAsync(\"processes\", {\n select: `{states:entitystates.where(entitytype.name=\"${type}\").orderby(numericPriority).select(id),`\n + `planned:entitystates.where(entitytype.name=\"${type}\" and isplanned=true).first().id}`,\n where: `projects.count(id=${args.Current.Project.Id})>0`\n});\n\nconst states = processes[0].states;\nconst planned = processes[0].planned;\nconst targetState = planned ? states[states.indexOf(planned) + 1] : states[1];\n\nreturn {\n command: \"targetprocess:UpdateResource\",\n payload: {\n resourceType: type,\n resourceId: args.ResourceId,\n fields: {\n EntityState: { ID: targetState}\n }\n }\n};"
}
]
Updated over 5 years ago