Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Copying a field using ScriptRunner behaviors in Jira Cloud

James Woyciesjes
Contributor
September 9, 2025

When I create a new issue, I would like to copy the description field from a template issue and put that description into the description field of the new issue, so it is displayed for the user on the create screen when it opens. We had the script in DataCenter but it doesn't work in Cloud.

I started here Set a default description when an issue is created for reference code but do not know how to pull the data from the template work item.

Example: I want to pull the description (or some custom field value) from work item AATPA-597 and insert it into the new issue being created so that it displays on the create screen.

Below is how I have it started.

 

// This script should be added to a Behavior mapped to the relevant project and issue type(s)

const descField = getFieldById("description")

const summary = getFieldById("summary")

const acceptancefield = getFieldById("customfield_10143")

issueTemplate = issueManager.getIssueObject("AATPA-724")

    getFieldById("description").setValue(issueTemplate.description)

    getFieldById("description").setValue(issueTemplate.summary)

    getFieldById("description").setValue(issueTemplate.getCustomFieldValue("customfield_10143"))

    summary.setFormValue(issueTemplate.summary)

2 answers

1 accepted

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
September 11, 2025

Hi James,

I can confirm it would be possible to achieve this requirement using behaviours in Jira Cloud. 

To do this, you would need to write a script that first fetches the issue you want to get the description from. We have an example of fetching fields from an issue here that you can use as a reference.  In this example you would change issueKey to be the key of your issue containing the template description. 

Your script will then be able to set the description with the fetch field value. We have an example of setting the description field here that you can use as a reference. 

I have created an example script here that shows how to copy a template description that you can modify to achieve your use case. 

I hope this helps.

Regards,

Kristian

James Woyciesjes
Contributor
September 11, 2025

Thank you Kristian. I was able to get the code to work.

A note on this page: Access fields from the issue object in Behaviours for Jira Cloud

It references .../rest/api//... and it should be a "3" for cloud like in the example script you provided.

Here is my final:

 

// Access the context for the UI Modification
const context = await getContext()

// Get the current issue key
const issueKey = "DEMO-724"

// Get the current issue object
const issue = await makeRequest("/rest/api/3/issue/" + issueKey);

// Get the decription of the issue in ADF format
const templateDescription = issue.body.fields.description;

// Set the description field to the fetched value
getFieldById("description").setValue(templateDescription);
Kristian Walker _Adaptavist_
Community Champion
September 12, 2025

Hi James,


Yes, for fields like description, where Atlassian switched to ADF, you will need to use V3 of the rest API, like in my example. 

I am glad you managed to get your script working. 

Regards,

Kristian

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2025

Hi @James Woyciesjes 

Other solution, create a new multi line text field, set this field on the create screen only.

In the context of the field you can set your default description, to be seen in the field when the issue is being created.

Then have an automation rule setup that based on issue creation copies the value from the field into the original description field, that is still on the edit and view screen.

James Woyciesjes
Contributor
September 10, 2025

Marc, thank you for the reply. I have considered this solution and know that it works and can use in the short term.

The reason I would like to use ScriptRunner behaviors is that our standard user does not have access to change the custom field context to update the default text if needed (not that it should happen often).

By setting up a template issue in an accessible project, the project manager/scrum master can adjust the default text at will without need of an admin.

My challenge is that I do know the code to get the description (or other field value) from work item AATPA-597 for example.

 

 

Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2025

Hi @James Woyciesjes 

I don't think behaviours can accommodate this in Cloud.

To be sure you could ask your question to script runner support.

Like James Woyciesjes likes this
James Woyciesjes
Contributor
September 11, 2025

@Marc - Devoteam Kristian was able to provide a method. Thanks again.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events