Automatically set the value of an Elements Connect field


Table of contents


There are many use cases where you want to define the value of a custom field programmatically. Either from a third party program using the Jira REST API or in the case of an automation process implemented in Jira.

Elements Connect fields, in addition to offering advanced editors that can be manipulated from an issue creation or editing form, can also be set programmatically. 

Several solutions are available to you, from the simplest to the most advanced:

Elements Connect post function

With the "Set a field value" post function you can set the value of an Elements Connect field from a workflow transition.



The Elements Connect post function configured on a workflow transition



When to use it

If you want to set or refresh a readonly Elements Connect custom field and don't need a conditional update.
It can also be used for Autocomplete fields but could lead to an undesired result because it is not possible to choose the value to select (the first value of the result set will be selected).

Learn more

Follow this documentation: Elements Connect post functions.

Automation for Jira - Elements Connect action

Automation for Jira is a tool you can use to automate tasks to extend Jira; it has been part of Jira Data Center since June 2022.

With this module, Jira admins and project admins can configure advanced automation following the IFTTT principle (If This Then That) by creating rules. A rule is a set of Triggers, Conditions, and Actions.

Elements Connect provides a custom Action: "Set Elements Connect field value".



Configuring the "Set Elements Connect field value" action in Automation for Jira



When to use it

This action behaves exactly like the Elements Connect post function "Set a field value". It is suitable for "Readonly" type fields. It can also be used for Autocomplete fields but could lead to an undesired result because it is not possible to choose the value to select (the first value of the result set will be selected).

Use it if you need an advanced control on when the field value shall be updated.

Additionally this solution can also be configured by Jira project admins, which can be a good thing if you want to offer them more autonomy.

Learn more

Automation for Jira documentation

Automation for Jira - Edit issue action

With the "Edit issue" action provided by Automation for Jira you can set the value of an Elements Connect field with more control.
It allows you to select the exact value of the Elements Connect field.

From the configuration screen of an Automation rule, click on More options to reveal the Additional fields editor.
In this editor, you can set field values the same way in the same way as you would when using Jira REST API.



Setting the value of the Elements Connect field of ID 10702 to 10877



In the example above, we set the value of an Elements Connect field (with ID 10702) connected to the Jira JQL datasource. The value selected is 10877, that is the ID of the value to set (in this case, it is a Jira issue ID).

That's the important thing to remember, if you want to set the value of a Live Elements Connect field (Live Text or Live User) with this method, you must pass the field stored value (its key), not the field display value. The value passed will be directly stored in the Jira database.

You can set dynamic values by using the smart values of Automation for Jira, as documented here.



Setting the value of the Elements Connect field of ID 10702 with a smart value



When to use it

If you want to set the value of any Elements Connect custom field of any type to a specific value.
Additionally this solution can also be configured by Jira project admins, which can be a good thing if you want to give them more autonomy.

Learn more

Automation for Jira documentation

Elements Connect Java API

When to use it

Elements Connect exposes a public Java API that can be used by developers who need to set an Elements Connect field value.

It can be used from:

  • a custom app development 
  • a ScriptRunner script

Learn more

Jira REST API

When to use it

Use it if you need to set the value of an Elements Connect field while creating / editing Jira issues using Jira REST API.

Learn more

Jira REST API