Is there a way to set a custom field value with script listener


we would like to set a custom field value on an event. At the moment, we already have a script listener sending out email notifications. Can we add setting the field to this listener?

And: If we can, please give a hint on how to set it.

2 answers

Below Groovy example is to set text Custom Field

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cf1 = customFieldManager.getCustomFieldObjects(issue).find { == 'cf1Name'};
def changeHolder = new DefaultIssueChangeHolder();
cf1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf1), 'newCf1Value'), changeHolder);;

Hello,  Does this also work for my custom field of type "select list (single choice)"?

Does Groovy script do this only after user Submits the form?

Is there any event fired right after a field is modified (new option selected, text filled in) that Script Runner can catch it even before the form submitted?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

463 views 7 5
Join discussion

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