/** This example script console script transitions issues returned from the JQL search which meet the specified conditions.* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or* amended and must be included in any circumstances where the code snippet is shared by You or a third party."*/// Variable to store the issue type to be matched ondefissueType="<IssueTypeNameHere>"// Variable to store the status to match ondefstatus="<StatusNameHere>"// The ID of the workflow transition to executedeftransitionID=<TransitionIDHere>defjqlQuery="<AddJQLQueryHere>"// Get all issues matching the specified JQL QuerydefallmatchingIssues=get("/rest/api/2/search").queryString("jql",jqlQuery).asObject(Map).body.issuesasList<Map>// Log out the number of issues returned by the JQL searchlogger.info("The number of issues returned by the JQL search = : ${allmatchingIssues.size()}")// Log out the map of issues returned by the JQL search.logger.info("The returned issues are "+allmatchingIssues)// Iterate over each issue returnedallmatchingIssues.each{it->// Get the issue object for each issue returned within the JQL searchdefissue=get('/rest/api/2/issue/'+it.key).header('Content-Type','application/json').asObject(Map)// Check if the issue in the issue type is in the specified statusif(issue.body.fields.status.name=="${status}"){// check if the issue is of the specified issue typeif(issue.body.fields.issuetype.name=="${issueType}"){// If all of the conditions are met transition the issuedeftransition=post('/rest/api/2/issue/'+it.key+'/transitions').header("Content-Type","application/json").body([transition:[id:transitionID]]).asObject(Map)}}}return"Script execution finished"
Comments (1)
Jason PinkhamAccount Deactivated
The search API call is what we were missing. I was going about that specific call the wrong way, but that just put me on the right track. Thank you!
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.
The search API call is what we were missing. I was going about that specific call the wrong way, but that just put me on the right track. Thank you!