On this page

Use case

Copy an excerpted value from the last comment using two delimiters when a new comment is posted and update a field with it.


Configuration

Create a new rule and name it appropriately.

Providing a description will help you to identify what the rule does but this step is optional.

Issue event


Add a Trigger → Issue event → Issue Commented

No further configuration is needed.

 Boolean condition


Add a Condition → Boolean condition

Expression

Adjust the following expression to restrict the scope of the automation to the project of your choice.

%{trigger.issue.project.key} = "PKEY"

 Update field action

Next to the boolean condition, add an ActionUpdate field

Field

For this use case, we will update the field Assignee.

Update to

Choose Value returned by parsed expression

Parser Expression

Set the mode to Advanced text and enter the following Parser Expression


first(findPattern(%{trigger.issue.lastComment}, "(?<=Assign to the user with ).*(?= username)"))

By replacing the texts "Assign to the user with " and " username" in the previous expression, you will be able to set different delimiters. The text between these delimiters will be copied.

Enable the rule by clicking on the Enable button → 

Import the example

Import the JSON file below to get started in no time.

JSON


After importing the JSON file, make sure to check the configuration of the rule. Non-existing configuration elements (issue types, fields, values etc.) will be highlighted.

{
    "name": "Copy excerpted value from new comments",
    "description": "Copy an excerpted value from the last comment using two delimiters when a new comment is posted and update a field with it.",
    "creator": "admin",
    "status": false,
    "triggerData": "6",
    "triggerType": "ISSUE_EVENT",
    "configuration": {
        "refs": [
            "issue",
            "system",
            "trigger.issue",
            "trigger.parent"
        ],
        "triggerType": "6"
    },
    "children": [
        {
            "sequence": 0,
            "type": "BOOLEAN_CONDITION",
            "ruleEntityType": "CONDITION",
            "configuration": {
                "refs": [
                    "issue",
                    "project",
                    "system",
                    "trigger",
                    "trigger.issue",
                    "trigger.parent"
                ],
                "expression": "%{trigger.issue.project.key} = \"PKEY\"",
                "expressionParsingMode": "logical",
                "actingUser": "field_00020"
            },
            "children": [
                {
                    "sequence": 0,
                    "type": "UPDATE_FIELD",
                    "ruleEntityType": "ACTION",
                    "configuration": {
                        "refs": [
                            "issue",
                            "project",
                            "system",
                            "trigger",
                            "trigger.issue",
                            "trigger.parent"
                        ],
                        "fieldId": "00003",
                        "mode": "parser",
                        "value": "first(findPattern(%{trigger.issue.lastComment}, \"(?<=Assign to the user with ).*(?= username)\"))",
                        "valueParsingMode": "textAdvanced",
                        "actingUser": "field_00020"
                    },
                    "children": null,
                    "hasChildren": false
                }
            ],
            "hasChildren": true
        }
    ],
    "hasChildren": true
} 

If you still have questions, feel free to refer to our support team.