Hi there
I have a Scriptrunner Listener Script that updates some fields based on an event.
I have set the event to "Comment Edited", but it applies to other events too.
The script will...
- ... correctly update all fields, if the event is fired by the native action of editing the comment.
- ... correctly update custom fields and the work logged, but NOT update the native fields, if the event is fired by a postfunction on a workflow transition.
I have made a video to demonstrate it:
https://drive.google.com/file/d/1AFBMXI2586AFd_6g2ppsfBCh4vr75Udw/view
Here is the script:
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.worklog.WorklogImpl2
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def worklogManager = ComponentAccessor.getWorklogManager()
def documentationField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Documentation")
Random rnd = new Random()
def myRandInt = rnd.nextInt(100)
def mutableIssue = issueManager.getIssueObject(event.issue.getId());
def worklog = new WorklogImpl2(mutableIssue, null, user.name, "My Comment", new Date(), null, null,myRandInt*3600, null)
worklogManager.create(user, worklog, myRandInt*3600, false)
log.debug("New Time Logged: " + myRandInt)
log.debug("Remaining: " + myRandInt)
mutableIssue.setEstimate(myRandInt*3600)
log.debug("Estimate: " + myRandInt)
def description = "Description: " + myRandInt
mutableIssue.setDescription(description)
log.debug("Description: " + description)
def documentation = "Documentation: " + myRandInt
mutableIssue.setCustomFieldValue(documentationField, documentation)
log.debug("Documentation: " + documentation)
//mutableIssue.store()
issueManager.updateIssue(user, mutableIssue, EventDispatchOption.ISSUE_UPDATED, false)
log.info("Issue "+mutableIssue.key+" updated")
There are no errors thrown and the logs are all correct.
This screenshot also shows you that the changes are protocolled in the history, but the (red) values are not written on the issue:

I am using Jira Server 7.7.1 and cannot upgrade at the moment as we are in the middle of a project.
Is this reproduceable on higher versions?