It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script to copy system and custom fields when a link is duplicates Edited

Hello Team,

We have a requirement to copy fields when a link is created which includes System and Custom field fields. We have "Automation for Jira", however it uses common user which doesn't track the who has done the changes.

Environment: Jira Cloud
Add-On: Script Runner for Jira Cloud

Can anyone help me with the sample script, that would be helpful and appreciated. I am beginner, I tried on my own referring existing sample scripts with no success.


When related record type is Duplicates and Initiating Dept = PSO CII and SFDC ID is not null then copy changes to current record to all children of type = Duplicates.

Initiating Dept: Single select custom field
SFDC ID: Single line text field
Issue Type: CII

Fields to be copied: Status, Priority, Assignee, Desc etc

I referred few scripts, They say specify issuekey: Does this mean happen only for specified key?


if ( == "Duplicate"){

def sourceIssueResponse = get("/rest/api/2/issue/${issueLink.sourceIssueId}").asObject(Map)
assert sourceIssueResponse.status == 200
def sourceIssueKey = sourceIssueResponse.body.key

def destinationIssueResponse = get("/rest/api/2/issue/${issueLink.destinationIssueId}").asObject(Map)
assert destinationIssueResponse.status == 200
def destinationIssueKey = destinationIssueResponse.body.key

def parentissue = get('/rest/api/2/issue/' + sourceIssueKey)
.header('Content-Type', 'application/json')

def parentPriority =

def updateissue = put('/rest/api/2/issue/' + destinationIssueKey)
.header('Content-Type', 'application/json')
priority : parentPriority




All looks fine, update isn't working fine, please help me

1 answer

Hi Suresh,

Thank you for your question.

I can advise that the best way to run your script would be to run the script as a Script Listiner which is configured to fire on the Issuelink Creted  event.

I would then advise that you click on the link named Show Me  next to the text which says There are parameters/variables that are automatically available for use within your script: in the Script Context dialog above the code box, in order to check if all the properties that you are accessing in your script without making a rest call to get them exist in the context of the script.

Also, I would advise checking the logs page as described here in order to check what happeneded during the execution of your script in order to identify why it did not execute as expected.



Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you