Set custom field value in Automation rule based on a Jira Text field
Objective
Learn how to set the value of a Elements Connected custom field in Automation for Jira rule, based on a Jira Text field.
Tutorial
Prerequisites
Elements Connect is installed on your Jira Cloud instance
A Jira Text field (Single line) has been created and added to the relevant project/screen (let’s say the project is PM).
The ID of the created Jira Text field has been identified (follow this KB to find your custom field ID). Let’s say the ID is “customfield_yyyyy”
A REST API datasource has been set up, connected to the local Jira instance (tutorial explained here), and successfully tested in Elements Connect.
Steps
We need to set the value of a Connected custom field, Issue picker, plugged to local Jira REST API.
Case 1 - Set Snapshot custom field
Custom field configuration
Create a Connect custom field, Select list single value.
In the “Customize look & feel” section, set the custom field type as Snapshot.
Set the template as below (the field will display and store the issue key).
Save your field configuration
Add the field to a project/screen (let’s say the project is PM)
From the Elements Connect administration page, note the Connect custom field ID (let’s say it's customfield_xxxxx)
Automation rule configuration
In Automation for Jira, create a rule as below:
Trigger: Manually triggered (or any trigger of your choice).
Action: Edit issue
Select “More options” and in “Additional fields” section, paste the below
CODE{ "fields":{ "customfield_xxxxx":"{{issue.fields.customfield_yyyyy}}" } }
Replace customfield_xxxxx by the ID of your Connect field, customfield_yyyyy by the ID of your Jira Text field:
Set rule name and publish it.
Trigger the rule manually from the project where you’ve added the Jira text field and the Connect field (let’s say the project is PM) and the value of the Text field will be copied into the Connect field
It’s mandatory that the value in the Jira Text field matches the value defined in the field Template.
Case 2 - Set Object custom field
Custom field configuration
Create a Connect custom field, Select list single value.
In the “Customize look & feel” section, set the custom field type as Object.
Check the option Recalculate displayed value on issue view
In the Live path section, use the below (where customfield_xxxxx is the ID of the current Connect custom field)
In the Template section (this means that for this object, we will store the issue id in its ID attribute, and issue key will be stored in the template attribute)
Save your field configuration
Add the field to a project/screen (let’s say the project is PM)
Automation rule configuration
In Automation for Jira, create a rule as below:
Trigger: Manually triggered (or any trigger of your choice).
Action: Edit issue
Select “More options” and in “Additional fields” section, paste the below
CODE{ "fields":{ "customfield_xxxxx":{ "id":"{{issue.fields.customfield_yyyyy}}", "value":"" } } }
Even if the value attribute is empty, it remains mandatory.
Replace customfield_xxxxx by the ID of your Connect field, customfield_yyyyy by the ID of your Jira Text field:
Set rule name and publish it.
Trigger the rule manually from the project where you’ve added the Jira text field and the Connect field (let’s say the project is PM) and the value of the Text field will be copied into the Connect field
It’s mandatory that the field is Live (the option “Recalculate displayed value on issue view” is checked) and that value in the Jira Text field matches the value defined in the Object ID attribute