Skip to main content
Skip table of contents

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.

    2024-12-24 13_50_01-Elements Connect - Configuration - Jira.png

  • 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).

    2024-12-23 16_10_25-Elements Connect - Configuration - Jira.png

  • 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)

    2024-12-23 16_21_38-Elements Connect - Configuration - Jira.png

Automation rule configuration
  • In Automation for Jira, create a rule as below:

    • Trigger: Manually triggered (or any trigger of your choice).

    • Action: Edit work item fields

      • 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:

        image-20250430-072843.png
    • 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.

    2024-12-24 13_49_00-Elements Connect - Configuration - Jira.png

  • 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)

    2024-12-24 13_58_53-Elements Connect - Configuration - Jira.png
  • 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)

    2024-12-24 14_00_59-Elements Connect - Configuration - Jira.png

  • 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 work item fields

      • Select “More options” and in “Additional fields” section, paste the below

        CODE
        {
           "fields":{
              "customfield_xxxxx":{
                 "id":"{{issue.fields.customfield_yyyyy}}",
                 "value":""
              }
           }
        }

        (info) 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:

        image-20250430-072934.png
    • 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


Case 3 - Set User custom field

Custom field configuration
  • Create a Connect custom field, User - Select list (single choice):

    image-20250218-083617.png
  • In the “Customise Look & Feel” section, set the ID you want, either ${row.accountId} or ${row.emailAddress}. Please note that this will not affect the automation rule below, which can only populate a user field using the accountId attribute:

    image-20250218-084046.png

2 methods are available, depending on whether you want to use an email address or an account ID:

A. Using an Account ID

Automation rule configuration
  • In Automation for Jira, create a rule as below:

    • Trigger: Manually triggered (or any trigger of your choice).

    • Action: Edit work item fields

      • Select “More options” and in “Additional fields” section, paste the below

        CODE
        {
           "fields":{
              "customfield_XXXXX":{
                 "accountId":"{{issue.fields.customfield_yyyyyy}}"
              }
           }
        }
      • Replace customfield_XXXXX by the ID of your Connect field, customfield_yyyyy by the ID of your Jira Text field:

        image-20250430-073026.png
    • 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

To populate a user field, customfield_yyyyyyy must contain a valid user account ID.

B. Using an email address

The principle is the same as with the first method, and we will use the account ID to populate the User field, but with an additional step to retrieve the account ID from the user's email address.

Automation rule import

For your inconvenience, you can import the following automation rule directly into your Jira instance: automation-rule-set-connect-user-field-using-email-address.json

Once imported, you will need to update it based on your specific configuration:

  1. Edit the Send Web Request action:

    • In the Web Request URL, replace customfield_yyyyy with the ID of your Jira Text field.

    • In the Authorization header, replace ENCODED_BASE_64_TOKEN with the token you generated by following the procedure described here: How to encode a Token to Base 64?

  2. Edit the Edit work item fields action:

    • Replace customfield_XXXXX with the ID of your Connect field.

Automation rule configuration
  • In Automation for Jira, create a rule as below:

    • Trigger: Manually triggered (or any trigger of your choice).

    • 1st Action: Send Web Request

      • Web request URL:

        CODE
        https://YOUR_JIRA_BASE_URL.atlassian.net/rest/api/3/user/search?query={{issue.customfield_YYYYY}}

        (info) Replace YOUR_JIRA_BASE_URL according to your own Jira instance, and customfield_yyyyy by the ID of your Jira Text field

      • HTTP method: GET

      • Web request body: EMPTY

      • Activate the option “Delay execution of subsequent rule actions until we've received a response for this web request“

      • Headers:

        CODE
        Authorization: ENCODED_BASE_64_TOKEN
        Content-Type: application/json

        (info) Generate ENCODED_BASE_64_TOKEN by following the procedure described here: How to encode a Token to Base 64?

    • 2n Action: Edit work item fields

      • Select “More options” and in “Additional fields” section, paste the below

        CODE
        {
           "fields":{
              "customfield_XXXXX":{
                 "accountId":"{{webResponse.body.accountId}}"
              }
           }
        }
      • Replace customfield_XXXXX by the ID of your Connect field:

        image-20250430-073200.png
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.