Skip to main content
Skip table of contents

Copy data using a script

Working principle

This page explains how to use a script from the Scriptrunner for Jira application to copy values from Connect fields to Jira Text fields.

To use this solution, you need to have ScriptRunner for Jira installed on your Jira instance with a valid license.

Steps

1. Prepare the script

The script contains some options that you need to change according to your needs. Please perform the following actions

  • Download the following file: SCRIPT - V2.txt

  • Edit this file to suit your needs, and update the options below accordingly…

A. Specify a JQL query

You will need to replace JQL_QUERY with a valid JQL query returning all the issues to update.

B. Option to generate a log report

The createLogReport variable allows the generation of a log file containing all the actions performed by the script:

Value

Action

createLogReport = true

A log report will be generated and can be found in the Jira in the Jira's temp directory.

createLogReport = false

No log report will be generated.

If you are experiencing issues, we recommend that you enable this option, reproduce the problem, and share the log file with our Support team

C. Option to prevent issue update

The silentUpdate variable allows the script to update issues silently. This means that changes will not appear in the issue history, and the “Issue Updated” field will remain unchanged:

Value

Action

silentUpdate = true

Connect fields will be copied without updating Jira issues, but this may impact Jira performance.

silentUpdate = false

Connect fields will be copied, and Jira issues will be updated accordingly.

D. Field mapping

In the fieldsMapping variable, you need to map the Connect fields to their respective Jira Text fields and specify the data to be copied.

It's a three-column table that must be structured as follows:

  • 1st column: ID of the source Connect field

  • 2nd column: ID of the target Jira Text field

  • 3rd column: Value to copy from the source Connect field

The third column is optional. If it is not specified, a default value will be copied from the Connect field, depending on its type.

Connect field type

Available values

Default copied value

Live Text

  • key

  • template

key

Live User

  • mail

  • key

  • template

mail

Snapshot (Text, Date and Datetime)

ℹ️ For Date and Datetime fields, Jira’s standard format will be applied, regardless of the format configured in Elements Connect.

  • template

template

The value to be copied is case-sensitive and must exactly match the format shown in the table above.

For Live User fields, copying the email address is strongly recommended, as it's the only common identifier between Jira Data Center and Jira Cloud.

Note that usernames in Jira Data Center do not exist in Jira Cloud, and user account IDs generated in Jira Cloud have no equivalent in Jira Data Center. Relying on the email ensures accurate user mapping across platforms.

Example:

CODE
def fieldsMapping = [
    ['customfield_11111','customfield_22222','key']
    ['customfield_33333','customfield_44444','template'],
    ['customfield_55555','customfield_66666','mail'],
    ['customfield_77777','customfield_88888']
];

2. Run the script

Once the above-mentioned options have been carefully adjusted to fit your needs, proceed as follows:

  • Open ScriptRunner for Jira.

  • Go to the Jobs tab

  • Click on “Create job” and create a “Custom scheduled job

  • Configure it as follows:

    • User: Select an Administrator of your Jira instance

    • Interval/Cron expression: Specify a unique date and time for the script to execute. For instance, to run the script on January 1, 2026, at 12:00 PM, use the following Cron expression:

      CODE
      0 00 12 1 1 ? 2026
    • Inline script: Paste the script you previously prepared

  • Save your job and wait for it to execute.

To test the script, you can start by using a restrictive JQL query that only returns a few issues. Then click on “Run now” to ensure that the script is working correctly.

Once the script has been validated, you may update the JQL query to process all relevant issues. However, do not click on "Run now" in this case, as executing the script manually on a large number of issues may lead to a timeout.

To safely process a large number of issues and avoid timeout risks, it's recommended to let the job to run in background according to the Cron expression you have set up.

Similarly, it's not recommended to run this script via the Console tab if a large volume of issues is concerned.

JavaScript errors detected

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

If this problem persists, please contact our support.