Add links to the issues in a ScriptRunner Issue Picker field

Use case

Add links to the issues included in a ScriptRunner Issue Picker field and delete them automatically if the issues are removed from the field.


⚒️ 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.

Field changed event

Add a trigger → Field changed event

Field

Select the ScriptRunner Issue Picker field

Change to

Select Any value

Boolean condition

Add a Condition next to the trigger → Boolean Condition 

Expression

Use the following Parser Expression after replacing the project key with the one of the project of your choice.

Bash
%{trigger.issue.project.key} = "CASE"

Next to the Boolean Condition click on Add → Action → Delete issue link

Issue link type

Choose relates to (Relates)

Issue selection

Choose All issues

Please, note that this automation will remove all of the issues linked with "relates to" issue type every time that it is executed. If there are more issues than those included in the ScriptRunner Issue Picker field, they will be lost permanently.

We recommend that a issue link type reserved only for the purpose of creating issue links for this field is used.

Boolean condition

Add a Condition under the action → Boolean Condition 

Expression

Use the following Parser Expression after replacing the field code %{trigger.issue.cfaaaaa} with the one for the ScriptRunner Issue Picker field.

Bash
%{trigger.issue.cfaaaaa} != NULL

Next to the Boolean Condition click on Add → Action → Create issue link

Issue link type

Choose relates to (Relates)

Issue selection

Choose Issue List Expression

Use the following Parser Expression after replacing the field code with the one for the ScriptRunner field.

Bash
issueKeysToIssueList(%{trigger.issue.cfaaaaa})

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.

JavaScript
{
    "name": "Add links to the issues in a ScriptRunner Issue Picker field",
    "description": "Add links to the issues included in a ScriptRunner Issue Picker field and delete them if the issues are removed from the field automatically.",
    "creator": "admin",
    "status": false,
    "triggerData": "",
    "triggerType": "FIELD_CHANGED_EVENT",
    "configuration": {
        "refs": [
            "issue",
            "system",
            "trigger.issue",
            "trigger.parent"
        ],
        "fieldId": "10700",
        "option": "any"
    },
    "children": [
        {
            "sequence": 0,
            "type": "BOOLEAN_CONDITION",
            "ruleEntityType": "CONDITION",
            "configuration": {
                "refs": [
                    "issue",
                    "project",
                    "system",
                    "trigger",
                    "trigger.issue",
                    "trigger.parent"
                ],
                "expression": "%{trigger.issue.project.key} = \"CASE\"",
                "expressionParsingMode": "logical",
                "actingUser": "field_00020"
            },
            "children": [
                {
                    "sequence": 0,
                    "type": "DELETE_ISSUE_LINK",
                    "ruleEntityType": "ACTION",
                    "configuration": {
                        "refs": [
                            "issue",
                            "project",
                            "system",
                            "trigger",
                            "trigger.issue",
                            "trigger.parent"
                        ],
                        "issueLinks": [
                            "inwards_10003"
                        ],
                        "destinationIssueSelection": "allIssues",
                        "destinationIssueSelectionIssueKeyParsingMode": "textAdvanced",
                        "actingUser": "field_00020"
                    },
                    "children": null,
                    "hasChildren": false
                },
                {
                    "sequence": 2,
                    "type": "BOOLEAN_CONDITION",
                    "ruleEntityType": "CONDITION",
                    "configuration": {
                        "refs": [
                            "issue",
                            "project",
                            "system",
                            "trigger",
                            "trigger.issue",
                            "trigger.parent"
                        ],
                        "expression": "%{trigger.issue.cf10700} != NULL\r\n",
                        "expressionParsingMode": "logical",
                        "actingUser": "field_00020"
                    },
                    "children": [
                        {
                            "sequence": 0,
                            "type": "LINK_ISSUE",
                            "ruleEntityType": "ACTION",
                            "configuration": {
                                "refs": [
                                    "issue",
                                    "project",
                                    "system",
                                    "trigger",
                                    "trigger.issue",
                                    "trigger.parent"
                                ],
                                "issueLinkType": "inwards_10003",
                                "destinationIssueSelection": "issues",
                                "destinationIssueSelectionIssues": "issueKeysToIssueList(%{trigger.issue.cf10700})",
                                "destinationIssueSelectionIssueKeyParsingMode": "textBasic",
                                "actingUser": "field_00020"
                            },
                            "children": null,
                            "hasChildren": false
                        }
                    ],
                    "hasChildren": true
                }
            ],
            "hasChildren": true
        }
    ],
    "hasChildren": true
}


📚 Related use cases