Jira Automation: How to copy custom field values to the trigger issue using the Parent Link field (without using branch blocks)
Summary
There are a few limitations to the Action blocks on Jira Automation for on-prem solutions when compared to the current options available on the Jira Cloud, such as Variables and LookUpIssues that allows us to move values inside the rule's scope or to create a list of issues from which we can perform actions outside the branch scope.
Solution: Send web request action block for Jira's REST API
Jira has a few inbuilt options to use the REST API inside the Automation rules.
If the rule was triggered by an issue (the example {{triggerissue}} is KAN-42) the next step is to have a source issue key to GET or PUT values into.
In this example, we'll use the "Parent Link" field, which has a parent issue key "KAN-35".
We'll need to authenticate a user that will be the REST actor. However, since Jira's REST API is well documented this can be done in several ways, and for this "proof-of-concept" example we'll not develop further on the authentication steps and the examples use the basic hashed password exactly as this guide:
1. Action: Send web request:
Use the Action block Send web request to run a GET on the issue we need to get values from:
<jira-URL>/rest/api/latest/issue/<ISSUE-KEY>?fields=<CF_ID>&fields=<CF_ID>...
Notice that we can use smart values for several parametrisable values such as Jira's URL and Parent Link fields.
Optional: Verify the URL request, responses, and payloads:
2. Smart-Values to use the payload's contents:
Here's the trick! By using the smart value:
{{webhookResponse.body.<key/value/etc>}}
Using dot notation we can retrieve the response structure mentioned from our GET:
{{webhookResponse.body.fields.customfield_10110.value}}
I.e: fields > customfield_10110 > 127
Different custom field types will have parameters, the tag containing the value we want might change to "key" or some other, check on the JSON to find the correct one for each case.
Example: Action: Edit issue
On the "Edit issue action" block we can set the values in any available field, as long as the field accepts the value format:
{{webhookResponse.body.fields.customfield_10110.value}}
This smart value can also be used with the Conditions, Actions, and Branch blocks.
Find more details and other smart values for this feature on this page: webhookResponse