Hi all,
I'm using a ScriptRunner job to update a custom field in Jira Data Center 9.4, like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.user.util.UserManager
UserManager userManager = ComponentAccessor.userManager
ApplicationUser user = userManager.getUserByName("automation-user")
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getComponent(IssueManager.class)
MutableIssue issue = issueManager.getIssueByCurrentKey("FOOBAR-10175")
CustomField myCustomFieldField = customFieldManager.getCustomFieldObjectsByName("My Custom Field").first()
IssueIndexingService issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
String myCustomField = "2"
issue.setCustomFieldValue(myCustomFieldField,myCustomField)
//
// Register the changes for the issue
issueManager.updateIssue(
user,
issue,
EventDispatchOption.ISSUE_UPDATED,
true
)
issueIndexingService.reIndex(issue)
The update happens fine and I can see the change in the issue history. However, the issue doesn't show up when I use the following JQL query:
issuekey = "FOOBAR-10175" and issuekey in updatedBy("automation-user"))
I do see the results if I search for the value of the field, like this:
issuekey = "FOOBAR-10175" and "My Custom Field" ~ "2"
So I know the issue got re-indexed properly after the update was made. The "issuekey in updatedBy()" clause works for other changes that have been made so I think I might need to add something to my script to get the right trail in place for the changes I'm making in the script. Any ideas what might be missing?