I am using a groovy listener to update a field with the following code snippet
MutableIssue issue = event.issue as MutableIssue
log.setLevel(org.apache.log4j.Level.DEBUG)
//Get current state of the indexer (usually false/disabled)
def wasIndexing = ImportUtils.indexIssues;
ImportUtils.indexIssues = true;
// define some generic stuff used by all
CustomField cfID = cfm.getCustomFieldObjectByName("GlobalID")
def issueM = cm.getInstance().getIssueManager();
def indexM = cm.getIndexManager();
//==============================================================================
// Set the user to the admin user to get admin rights
def admin_user = cm.getUserUtil().getUser("admin")
cm.getJiraAuthenticationContext().setLoggedInUser(admin_user)
... (more code but no edits to issue )
issueWatermark = issueM.getIssueObject("ADMIN-1")
def vNextID = issueWatermark.getCustomFieldValue(cfID)
//--------------------------------------------------------------------------------------
// Assign ID to issue
IssueInputParameters setIDParameters = new IssueInputParametersImpl();
setIDParameters.addCustomFieldValue(cfSonicsID.getId(), vNextID)
def updateIDValidationResult = issueService.validateUpdate(admin_user, issue.getLong("id"), setIDParameters);
if (updateIDValidationResult.isValid()) {
def updateIDResult = issueService.update(admin_user, updateIDValidationResult, EventDispatchOption.DO_NOT_DISPATCH, false);
indexM.reIndex(updateIDResult.getIssue())
log.debug "Setting ID for issue "+issue.getKey()+" to "+vNextID.toString()
} else {log.debug "no ID update on "+issue.getKey();}
}
Line number 31 passes for a "Task" type but fails for a "sub-task". The admin_user is in the admin group, so he shouldn't have any permission problems. From the log command, I can see that the key is for the right issue (e.g. not the parent issue). What could possibly cause it to not work on sub-task creation?
I do a reIndex on a different issue in the missing code (...). Perhaps, that is messing me up some how.
George