Im doing a condition to be ....
Issue was previously in status 'Review'
This is basically so i can set a resolution depending on what route the user went around the workflow.
Thanks
Here is an example of running JQL in a script:
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
String jqlSearch = "status changed from \"Status 1\" to \"Status 2\""
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
UserUtil userUtil = ComponentAccessor.getUserUtil()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()
List<MutableIssue> issues = null
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
SearchResults searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.getResults().collect {issueManager.getIssueObject(it.id)}
} else {
log.error("Invalid JQL: " + jqlSearch);
}
Hi Payne, thanks so much for you help.
Im getting the below error when i put this into my condition....
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.search.SearchResults.getResults() is applicable for argument types: () values: [] Possible solutions: getIssues()
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 running an older version of Jira than we are (8.5); getIssues() was replaced with getResults() somewhere along the way. My script is an updated version of one that I found at https://community.atlassian.com/t5/Marketplace-Apps-Integrations/How-to-run-JQL-query-inside-Groovy-script/qaq-p/194691 Try that one and see if it works for you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Excellent! Thanks again for your help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can i ask is it possible to get a results of true or false rather than issues? Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure; you can conclude with a line like this:
return issues.size() > 0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Payne, but for some reason im not getting the correct result. My JQL is correct when i run that but in this condition its not working it thinks its true. But if i misspell a status it does what its meant to and comes out false. Hope that sort of makes sense?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it's returning true, then the List must contain one or more issues. Remove the new line (return issues.size() > 0) and see which issues are being returned. You may need to refine your JQL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use status was "Some Status"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Payne, sorry im confused what you mean?
Im looking for a script just like the JQL
status changed FROM "Status 1" TO "Status 2"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I thought you were seeking the JQL. I'm attaching a script as a new answer.
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.