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

How set custom field value in Issue Create event Edited

Hello everybody. I try to make Script Listener, which in the time of issue creation make a Issue in another instance of jira via REST and I want to parse response to get ID of created issue and set that ID in to custom field, but I can't. Is it possible to set value in custom field via script listener when Issue Create event happens?   

def issue = event.getIssue()

def key = issue.key

MutableIssue mI = ComponentAccessor.getIssueManager().getIssueByCurrentKey(key)

mI.setCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Issue ID"),"here is ID from response")

And why I can't use this

def issue = event.getIssue()

issue.setCustomFieldValue(cF, value)


1 answer

1 accepted

1 vote
Answer accepted


1) event.issue returns "Issue" interface, it doesn't have setCustomFieldValue methoid.
You need "MutableIssue" interface you want to update this issue.
2) From API

void setCustomFieldValue(CustomField customField, Object value)
Sets a custom field value on this Issue Object, but does not write it to the database. This is highly misleading. To actually set a custom field value, use OrderableField.updateIssue(com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem, MutableIssue, java.util.Map)

So you need "updateIssue" method from IssueManager

def CF = customFieldManager.getCustomFieldObject(<fieldID>);
MutableIssue issueToUpdate = (MutableIssue) event.issue;
issueToUpdate.setCustomFieldValue(CF, <newValue>);
issueManager.updateIssue(event.getUser(), issueToUpdate, EventDispatchOption.ISSUE_UPDATED, false);


Thanks a lot, it works.

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