Script Runner: Clones an issue, and links

How can I use the below script to set the value of an issue field such as "Description" instead of a custom field?

def cf = customFieldManager.getCustomFieldObjects(issue).find { == 'field name'}
issue.setCustomFieldValue(cf, 'Non-project')

Also how can I use the above script or a mod of it to set a date picker custom field to 3 days from the current date?


Thanks for your help guys.



1 answer

0 votes

I think this page in our documentation is exactly what you are looking for:

Essentially, you can set non-custom fields like this in post-functions:

// system fields
"A generated description")
new Timestamp((new Date() + 1).time)) // set due date to tomorrow

Hi Joshua,


Thanks for the help.

Using your input I built the below script. The script is parsed and no errors are shown but it is not creating a linked item. Please let me know where I am going wrong here!

def cf = customFieldManager.getCustomFieldObjects(issue).find { == 'Project Name'}
issue.setCustomFieldValue(cf, 'Non-project')
issue.setDescription('Review the listed exception(s) for approval.')
def usercf = customFieldManager.getCustomFieldObjects(issue).find { == 'Deloitte/Technical Lead'}
issue.setCustomFieldValue(cf, 'VDLT DL QualityTeam')
def textcf = customFieldManager.getCustomFieldObjects(issue).find { == 'Estimate'}
issue.setCustomFieldValue(cf, '1')
def dateCf = customFieldManager.getCustomFieldObjects(issue).find { == 'Desired Completion Date'}
issue.setCustomFieldValue(dateCf,((new Date() + 1)))





Hi David,

There are two things I'd look at.

First, did you place that code in the "Additional issue actions box"? It should go in the Additional issue actions box, not the Condition box.

Screen Shot 2017-08-21 at 2.20.52 PM.pngSecondly, did you put the post function in the correct order? Your post function should be the very last thing, like this:

Screen Shot 2017-08-21 at 2.22.46 PM.pngFinally, remember to publish your workflow.

Hi Joshua,

Still no luck sorry. Here is my setup:



Hi David, 

Your setup looks correct. I think you are very close to getting this to work. One problem I noticed is that your script doesn't define the customFieldManager.

Add this to the top of the script:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

Another thing is that the usercf field may not be able to be set like that. What type of field is usercf? Is it a user picker field, group picker, etc? You might try commenting out or removing the lines where you get usercf and set usercf and then try to run the script again after adding the above code.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,082 views 4 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you