Append Tags

👍

You can find more examples at the Automation Rules page

📘

How to apply this rule?

Append Tag

The rule appends 'urgent' tag to Requests with 'Urgent' keyword in the title (with the replacement if current Tags).

[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "UserStory"
    ],
    "modifications": {
      "created": false,
      "deleted": false,
      "updated": [
        "Name"
      ]
    }
  },
  {
    "type": "filter:Relational",
    "or": [
      {
        "and": [
          {
            "target": {
              "type": "field",
              "name": "Name",
              "target": {
                "type": "pipelineBlockOutput"
              }
            },
            "value": {
              "type": "constant",
              "value": "Urgent"
            },
            "operator": {
              "type": "contains"
            }
          }
        ]
      }
    ]
  },
  {
    "type": "action:targetprocess:UpdateEntity",
    "fields": {
      "Tags": {
        "type": "constant",
        "value": "Urgent"
      }
    },
    "target": {
      "type": "pipelineBlockOutput",
      "blockAlias": "ui:source"
    }
  }
]

Append Tag without the replacement of current Tags

The rule appends 'newtag' tag to User Stories with 'Urgent' keyword in the title.

[
  {
    "type": "source:targetprocess:EntityChanged",
    "entityTypes": [
      "UserStory"
    ],
    "modifications": {
      "created": true,
      "deleted": false,
      "updated": [
        "Name"
      ]
    }
  },
  {
    "or": [
      {
        "and": [
          {
            "target": {
              "type": "field",
              "name": "Name",
              "target": {
                "type": "pipelineBlockOutput"
              }
            },
            "value": {
              "type": "constant",
              "value": "Urgent"
            },
            "operator": {
              "type": "contains"
            }
          },
          {
            "target": {
              "type": "field",
              "name": "Tags",
              "target": {
                "type": "pipelineBlockOutput"
              }
            },
            "value": {
              "type": "constant",
              "value": "newtag"
            },
            "operator": {
              "type": "not contains"
            }
          }
        ]
      }
    ],
    "type": "filter:Relational"
  },
  {
    "type": "action:JavaScript",
    "script": "const tags = args.Current.Tags;\n\nreturn {\n  command: \"targetprocess:UpdateResource\",\n  payload: {\n    resourceType: args.ResourceType,\n    resourceId: args.ResourceId,\n    fields: {\n      Tags: tags ? tags + \", newtag\" : \"newtag\"\n    }\n  }\n};"
  }
]