Inherit Portfolio Epic from Epic to its Features
Inherit Portfolio Epic when Feature is added to an Epic
![pe1.png 1140](https://files.readme.io/4fa51ca-pe1.png)
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"Feature"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"Epic"
]
}
},
{
"or": [
{
"and": [
{
"value": null,
"target": {
"name": "Epic",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
},
"operator": {
"type": "exists"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:targetprocess:UpdateEntity",
"fields": {
"PortfolioEpic": {
"name": "PortfolioEpic",
"type": "field",
"target": {
"name": "Epic",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
"target": {
"type": "pipelineBlockOutput",
"blockAlias": "ui:source"
}
}
]
When Portfolio Epic for an Epic is changed, change it for all Epic's Features
![pe2.png 1153](https://files.readme.io/3589e85-pe2.png)
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"Epic"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"PortfolioEpic"
]
}
},
{
"type": "action:JavaScript",
"script": "//get the list of all Features\nconst api = context.getService(\"targetprocess/api/v2\");\nconst featureIds = await api.queryAsync(\"Feature\", {\n \"select\": \"id\",\n \"where\": \"epic.id =\" + args.ResourceId\n});\nif (!featureIds || !featureIds.length) { return; }\n\n//set Portfolio Epic for all Features\nconst pe = args.Current.PortfolioEpic ? { Id: args.Current.PortfolioEpic.Id } : null;\nreturn featureIds.map(value => ({\n command: \"targetprocess:UpdateResource\",\n payload: {\n resourceId: value,\n resourceType: \"Feature\",\n fields: {\n PortfolioEpic: pe\n }\n }\n}));"
}
]
Updated almost 5 years ago