Close an item on its Planned End Date
Close Features on their Planned End Date

[
{
"type": "source:schedule",
"schedule": {
"kind": "interval",
"unit": "day",
"value": 1
}
},
{
"type": "action:JavaScript",
"script": "const type = \"Feature\";\nconst filter = \"Project.Name='Mobile'\";\n\nconst api = context.getService(\"targetprocess/api/v2\");\nconst workItems = await api.queryAsync(type, {\n select: \"id\",\n where: `EndDate=null and ${filter} and PlannedEndDate==DateTime.Today`\n});\nif (!workItems || !workItems.length) { return; }\n\nreturn workItems.map(id => {\n return {\n command: \"targetprocess:MoveToState\",\n payload: {\n resourceType: type,\n resourceId: id,\n stateKind: \"Final\"\n }\n }\n});"
}
]
Updated over 5 years ago