Hello All,
I am using the Script Runner plugin and writing a custom listener. When a user updates a custom field of type Version picker (single) called "Service Increment" on an epic then my listener automatically updates the same custom field with same value on the child stories. This functionality is working perfectly fine.
Now, the problem is that when I run a JQL query like
type = story and "Service Increment" = SI-04
then it's unable to find the newly updated child story which has inherited the value SI-04 from the parent epic.
I have tried following approaches to update custom field value so that it's reflected in the index but it's just not working.
Approach 1
Using the updateValue method on the custom field object for the story object, it has always been working well with all custom fields and the value is also reflected in the index immediately but in this case it's just not working. It updates the value perfectly in the story but it's not reflected in the JQL
serviceIncrement.updateValue(null, story, new ModifiedValue(null, serviceIncrementValue), new DefaultIssueChangeHolder())
Approach 2
Using the issueManager, again this works well but the value is not appearing in the JQL
story.setCustomFieldValue(serviceIncrement, serviceIncrementValue)
issueManager.updateIssue(user, story, EventDispatchOption.ISSUE_UPDATED, false)
Approach 3
Using the IssueService and IssueInput parameters, and again same result value is updated on the story but not appearing in JQL
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.addCustomFieldValue(serviceIncrement.getId(), serviceIncrementValue.first().getId().toString())
def validateUpdate = issueService.validateUpdate(user, story.id, issueInputParameters)
if (validateUpdate.isValid()) {
def issueResult = issueService.update(user, validateUpdate, EventDispatchOption.ISSUE_UPDATED, false)
if (issueResult.isValid()) {
log.info "${issue.key} has been updated with new SI version"
} else {
log.error "${issue.key} failed to update the SI version" + issueResult.errorCollection.errorMessages
}
Approach 4
Adding the explicit indexing code and still the same result as above
serviceIncrement.updateValue(null, story, new ModifiedValue(null, serviceIncrementValue), new DefaultIssueChangeHolder())
def issueIndexService= ComponentAccessor.getComponent(IssueIndexingService.class)
boolean wasIndexing = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true)
issueIndexService.reIndex(story)
ImportUtils.setIndexIssues(wasIndexing)
And still the same results.
The only way to get the newly updated value immediately reflected in the JQL is by doing a complete project reindex.
Thus, please share your opinion.
Jira version - 7.11.2
Thanks,
Tarun