I am using JIRA 7.3.6 and Adaptavist scriptrunner 5.4.28
I have a Groovy Listener that changes a custom field value when either issueCreated or issueUpdated events happen. The field is being updated but a JQL search using that field does not give the correct results until the database is re-indexed.
log.debug "Updating Train field."
CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager()
def relTrainField = cfm.getCustomFieldObjects(issue).find {it.name == "ReleaseTrain"}
def changeHolderTrain = new DefaultIssueChangeHolder();
relTrainField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(relTrainField), newRT),changeHolderTrain);
Is there a better way to do this custom field change that will re-index the issue also?
Most examples that I can find for re-indexing use IssueIndexManager or IssueIndexService. When I try to use those, I get errors as if those have been deprecated. Is there a way to re-index an issue using the 7.3.6 API?
Thanks for any help
Hi George
I am using such listener code to update custom field value, try it
MutableIssue issueToUpdate = (MutableIssue) event.issue;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getIssueManager();
def cfield = customFieldManager.getCustomFieldObjectByName('<field name>');
issueToUpdate.setCustomFieldValue(cfield, <value>);
issueManager.updateIssue(event.getUser(), issueToUpdate, EventDispatchOption.ISSUE_UPDATED, false);
That worked. I also notice one of the other Listener used the following without any errors.
def issueIndexingService = ComponentAccessor.getComponentOfType(IssueIndexingService.class)
issueIndexingService.reIndex(issue);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.