issueManager.updateIssue() does not update the issue field successfully


I have written this little Groovy script to update the timespent value on a ticket.

If I use to commit the change it works and the value is visibly different in the JIRA UI.

As this method is deprecated I want to use issueManager.updateIssue() instead.

Unfortunately this method does not update the issue field successfully (it still has the old value in the JIRA UI).

Could you please tell me what I am doing wrong here?

Best regards

Here is my full script:

//import all dependencies

import com.atlassian.jira.event.type.EventDispatchOption;

import com.atlassian.jira.issue.MutableIssue;

import com.atlassian.jira.component.ComponentAccessor;

import org.ofbiz.core.entity.ConnectionFactory;

import org.ofbiz.core.entity.DelegatorInterface;

import com.atlassian.jira.ofbiz.OfBizDelegator;

import groovy.sql.Sql;

import groovy.sql.GroovyRowResult;

import java.sql.Connection;

//prep variables

def totalTime = 0;

def sqlStatement;

def sqlSelect;

def sqlWhere;

def sqlJoins;

def issueManager;

MutableIssue timeboxIssue;

//NOTE: we need to set these values every sprint

//Id of new sprint

def currentSprint = “682”;

//ticket ID of Bugfixing Timebox

def timeboxIssueKey = “DEVANA-27898”;

// establish SQL connection

OfBizDelegator delegator = ComponentAccessor.getOfBizDelegator();

DelegatorInterface delegatorInterface = delegator.getDelegatorInterface();

String helperName = delegatorInterface.getGroupHelperName(“default”);

Connection connection = ConnectionFactory.getConnection(helperName);

Sql sql = new Sql(connection);

//get all bugs in current sprint that do not have an original estimate

sqlSelect = "SELECT ji.timespent, ji.summary FROM jiraissue ji ";

sqlJoins = "JOIN CustomFieldValue cfv on cfv.issue = JOIN CustomField cf on cf.Id = cfv.CustomField ";

sqlWhere = “WHERE ji.project = 11802 and cf.cfname = ‘Sprint’ and cfv.stringvalue = '”+currentSprint+ “’ and (ji.timeoriginalestimate is null or ji.timeoriginalEstimate = 0)”;

sqlStatement = sqlSelect + sqlJoins + sqlWhere;

List resultRows = sql.rows(sqlStatement);

//if there are no bugs in the current sprint we exit early

if (resultRows == null || resultRows.size() == 0) {

log.warn(“No result found”);




//get sum of all logged work


def timespent = “${it.timespent}”;


if (timespent != null){

totalTime += Integer.parseInt(timespent);



//set Bugfixing timebox of current sprint

issueManager = ComponentAccessor.getIssueManager()

timeboxIssue = issueManager.getIssueByCurrentKey(timeboxIssueKey);


//commit database changes to view

//decided to use this although it is deprecated as we just modify the timeboxIssue which does not contain critical data


//modern alternative, but it is not updating :frowning:

def newobject = issueManager.updateIssue(ComponentAccessor.getUserManager().getUserByName(“admin”), timeboxIssue, EventDispatchOption.ISSUE_UPDATED, false);

//close connections


return timeboxIssue.getTimeSpent();