Hi,
When i am trying to search by my scripted field (code below) for example:
"product done by it" ~ no - gives me back all issues (with yes, no, No IT tasks)
"product done by it" ~ yes - gives nothing even though i have some issues with "yes"
Of course i reindexed after change
Am i doing something wrong?
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
def searchForIssues(ApplicationUser searchUser, String initialJQL) {
def searchService = ComponentAccessor.getOSGiComponentInstanceOfType(SearchService)
def queryParser = ComponentAccessor.getOSGiComponentInstanceOfType(JqlQueryParser)
def query = queryParser.parseQuery(initialJQL)
SearchResults search = searchService.search(searchUser, query, PagerFilter.getUnlimitedFilter())
return search.results
}
def scriptResult = "Don't know"
enableCache = {-> false}
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def jql = "key in issueMatrix('${issue.key}', 'Tasks in IT Domains')"
def issues = searchForIssues(user, jql)
if (issues){
def result = issues.every{
log.error(it.status.name)
it.status.name == 'Done' || it.status.name == 'Canceled'
}
log.error(result)
if (result){
scriptResult = "Yes"
} else {
scriptResult = "No"
}
}
else{
scriptResult = "No IT tasks"
}
return scriptResult
Your script should output one of 4 values:
If you doa JQL with
"product done by it" ~ no
I'd expect all issues where you'd expect 2, 3 or 4 to be returned.
I'd look at the actual value returned for issues you know should return a "Yes" and make sure the script works as designed. I'm especially uncertain about the "in issueMatrix" function in this context.
But something else to consider, since you only have 4 discrete values in your script, there is no reason not to use the "Exact Text Searcher" then you will be able be more specific with your JQL
For example:
"product done by it" = Yes
"product done by it" = No
"product done by it" in (No, "No IT Tasks")
I also tried the "Exact Text Searcher" but unfortunately the problem must lie somewhere else because the values shown when searching in JQL are different from those in the issue itself
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It might be caused by enabledCache={->false}
In the documentation (https://docs.adaptavist.com/sr4js/latest/features/script-fields) there is this warning:
If your script relies on data from external system you can invalidate the cache altogether, although you should test first, particularly if you are doing things like running complex JQL queries.
I wonder if this is a case when disabling the cache is hurting you more than helping you.
I would try this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, nothing has changed. When searching only the first task is found correctly the rest of the searched tasks are all tasks that have any values in "product done by it".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.