Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can i print the entries in a list sorted by priority?

Annika Wäsch
October 23, 2023

How can i print the entries in a list sorted by priority - if i print them as a card, they stay in order, but i want to print them in a list.

2 answers

1 accepted

1 vote
Answer accepted
Steve Kamens
October 25, 2018

I got it working by transferring the data to a new object instead of passing back the Issues List:

 

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonOutput
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.PermissionManager
import com.atlassian.jira.permission.ProjectPermissions
import com.atlassian.jira.project.Project
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchException
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.Issue

class objSummary{
String key
String summary
}

@BaseScript CustomEndpointDelegate delegate

getEpicsInProject(httpMethod: "GET") { MultivaluedMap queryParams ->

def projectKey = queryParams.getFirst("project") as String

 

def retHash = [:]
def issueList = []
def errorList = []
def resultstatus = 1

def projData


if(projectKey == null){
resultstatus = 0
errorList.push('Invalid Project')
retHash["errors"] = errorList
}else{


def jqlSearch = "type = Epic and project = " + projectKey + " and status != Done" // the jql query you want to search with

ApplicationUser adminUser = ComponentAccessor.getUserManager()getUserByName("admin")
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(adminUser)
def searchService = ComponentAccessor.getComponentOfType(SearchService.class)
SearchService.ParseResult parseResult = searchService.parseQuery(adminUser, jqlSearch)
def isscount = 0


def results = searchService.search(adminUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def issues = results.getIssues()

issues.each(){Issue oneIssue ->
def oSum = new objSummary()
oSum["key"] = oneIssue.getKey()
oSum["summary"] = oneIssue.getSummary()



issueList.add(oSum)

}


retHash["issues"] = issueList

// results.clear()
// issues.clear()
//retHash["issues"] = searchService.searchCount(adminUser, parseResult.getQuery())


}

retHash["status"] = resultstatus

 



Response.ok(JsonOutput.toJson(retHash)).build()
}

Andrew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 30, 2018

Hi @Steve Kamens!

Is the problem relevant? If no, make your answer as accepted, please.

Thanks!

0 votes
Andrew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 25, 2018

Hi @Steve Kamens!

Check server logs atlassian/application-data/jira/log. What is there?

Steve Kamens
October 25, 2018

2018-10-25 11:22:32,917 http-nio-8080-exec-176 ERROR admin 682x33057x1 vk0t3k 172.28.145.52 /rest/scriptrunner/latest/custom/getEpicsInProject [c.o.s.r.rest.common.UserCustomScriptEndpoint] Script endpoint failed on method: GET getEpicsInProject
java.lang.StackOverflowError
2018-10-25 11:23:15,559 Caesium-1-4 ERROR ServiceRunner [o.o.c.entity.jdbc.SQLProcessor] !!! ABANDONED SQLProcessor DETECTED !!!
This probably means that somebody forgot to close an EntityListIterator.
Connection: DelegatingConnectionImpl[connectionPoolInfo=ConnectionPoolInfo{maxSize=20, minSize=20, initialSize=null, maxIdle=20, maxWait=30000, sleepTime=300000, lifeTime=600000, deadLockMaxWait=600000, deadLockRetryWait=10000, validationQuery='select 1', minEvictableTimeMillis=60000, timeBetweenEvictionRunsMillis=300000, poolPreparedStatements=null, testOnBorrow=false, testOnReturn=null, testWhileIdle=true, maxOpenPreparedStatements=null, numTestsPerEvictionRun=null, removeAbandonedOnBorrow=true, removeAbandonedOnMaintanance=null, removeAbandonedTimeout=300, validationQueryTimeout=3, defaultCatalog=null},sqlConnectionInterceptor=org.ofbiz.core.entity.jdbc.interceptors.connection.SafeDelegatingSqlConnectionInterceptor@58ad0bf7]

Suggest an answer

Log in or Sign up to answer