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

Why doesn't Script Listener write to Issue History?

We have a Script Listener that updates fields but doesn't update the History of the Issue.  Per Payne on an earlier question "...EVERY change (except comments and changes to comments) SHOULD be recorded in the History tab."

This is a snippet of the Groovy code:


* Fires when a Issue Link is created.
* Exits if Linked to Issue is not Initiative / Feature / Epic
* Copies Custom Fields down from Linked Issue

// imports...

// Setup Custom Field Manager
def CustomFieldManager = ComponentAccessor.getCustomFieldManager()

// Grab Event
def event = event as IssueLinkCreatedEvent

// sourceIssue is really the Issue that is being Linked to.
def sourceIssue = event.getIssueLink().getSourceObject()"sourceIssue: " + sourceIssue.key)

// Exit if not Initiative / Feature / Epic
if ( != "Epic" && != "Feature" && != "Initiative") {"Exiting ... sourceIssue type of: " + + " is not Epic / Feature / Initiative")
return 0

// Which makes the Destination object really the issue
def issue = event.getIssueLink().getDestinationObject()"issue: " + issue.key)

* Workfront Project

def CfWorkFrontProject = CustomFieldManager.getCustomFieldObject('customfield_10703')"CfWorkFrontProject")

// Copy if target Field IS Empty and source field is NOT Emtpy
if(!issue.getCustomFieldValue(CfWorkFrontProject) &&
) {
def oldData = issue.getCustomFieldValue(CfWorkFrontProject)
def newData = sourceIssue.getCustomFieldValue(CfWorkFrontProject)

CfWorkFrontProject.updateValue(null, issue, new ModifiedValue(oldData, newData), new DefaultIssueChangeHolder());"Workfront Project updated to: " + newData)
} else { ("Not CfWorkFrontProject && not value in CfWorkFrontProject")



When the listener is triggered, it does update the CfWorkFrontProject field but there's no corresponding log entry and we have no clue why.

Are we updating custom fields incorrectly?

My colleague and I are very new to Jira/ScriptRunner/Groovy and so may be writing some very offensive code.  For that we apologize.

1 answer

1 accepted

0 votes
Answer accepted

Hi @Bruce Mohler ,

You can use this code to have the update display in the history : 

import com.atlassian.jira.event.type.*
import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def sendMail = true
int cfId = 13401
def cfObject = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(cfId)
def cfNewValue = ....

issue.setCustomFieldValue(cfObject, cfNewValue)
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, sendMail)


Thank you, Antoine.  I'll try that this morning.

Antoine, we have some scripts which are using the IssueService rather than the IssueManager to change the values of custom fields (and they're not updating History either).

We're not really clear what the canonical way to update these fields is.

@Antoine Berry , when I paste those lines into the Script Console, the following 2 lines generate syntax errors:

def cfObject = getCustFieldObjectById(cfId)
issue.setCustomFieldValue(cfObject, cfNewValue)

The first can't find a method that accepts an int as an argument.

The second can't find a method that accepts an Object and String as arguments.

I'm a bit baffled.  I'm not sure whether I'm missing an import or 2?  I tried to search Google for getCustFieldObjectById (hoping to land in the Atlassian API documentation) but it kept trying to send me to another method (getCustomFieldObjectByName).


Antoine Berry Community Leader Sep 12, 2019

Hi @Bruce Mohler ,

I am terribly sorry, that is a custom method I am using and forgot to replace it. I updated the original answer with the correct code. It should work now if the cfNewValue fits to the custom field type.

IssueService is AFAIK the best way to update as you can check if the field can correctly be updated, so you can use that as well. 


Antoine Berry Community Leader Sep 12, 2019

Hi @Bruce Mohler , did that work for you ? In that case please make sure to accept the answer so it can help others in the future.

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