Hi! Please help.
I want create custom listener, which will perform the re-index issues (which are included in version or sprint), if release date changed.
I have a piece of code, but I can’t figure out how to get the list of issues in the release and reindex its.
def issueManager = ComponentAccessor.getIssueManager()
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
Version version = event.getVersion()
????
boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
log.warn("Reindex issue ${issue.key} ${issue.id}")
issueIndexingService.reIndex(issueManager.getIssueObject(issue.id));
ImportUtils.setIndexIssues(wasIndexing);
I think you have the right idea here - you've found the right bit of the doc about when scripted fields are updated (I don't like our docs much, as the really useful bit you've found is well buried and should be a lot more obvious but they are being reviewed and rewritten).
@JiraGuyis right in that it would be better to have the release date built automatically, but as it's a scripted field, the problem lies with the fact that there's no way for that field to know that something not directly related to the issue should trigger an update. It's not really a bug in Jira or Scriptrunner, just a hole in the functionality that falls down the gap between them! So your listener is the right idea, as it can tell those fields to update.
Short answer - there's a chunk of code at https://library.adaptavist.com/entity/perform-a-jql-search-in-scriptrunner-for-jira that iterates over a search result. Feed it with "version = <version that just changed>" to get a list of issues, then you can iterate over that with your indexing code (although I might swap to "issueIndexingService.reIndexIssueObjects(<list of issues>)" )
JIRA already does incremental indexing. Why do you want to add this extra step?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use this for a script field that displays the end date of the release. If the release date changes, then this does not lead to indexing of issues and because of this, sorting in the search for requests does not work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am still not sure. But I don't think this is the right way to approach this. I would recommend creating a support ticket with Atlassian. Search is something that should work in JIRA and if it isn't working, you have a problem with JIRA my friend.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, this is a feature of the script fields ScriptRunner =(
From the docs
It’s worth expanding a little on what I said above. You can only reliably use a calculated field to display a value that is based on the issue’s fields, or subtasks' fields, or linked issues. The reason why is because the value in the Lucene index is only updated when the issue is updated. If you compute some value based on data outside of the current issue, the value in the index may differ from the value displayed on the issue.
https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't been using this plugin for sometime now. It all makes sense now.
You might already know this.
If you have Atuomation for JIRA plugin, they have an event for Version Updated. You can then use their third party integration script-runner to execute your script.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.