Forums

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

Groovy How to get URLs from Collections$UnmodifiableRandomAccessList

Tomáš Vrabec
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 Leaders.
September 25, 2020

Hello community.

Need a little bit of help with parsing groovy.

Putting together auto-answer script for one of my customer. The goal is, to return a comment with number of incidents AND urls for accessing them from Customer Portal URL for matching JQL. I did all of the scripting, I can find the issues and return number of results. What I am unable to find out is the way, how to process and return the list of URLs for results. (could be more tickets).

Right now I am ending with variable of:

Your script ran successfully against issue FOO-0001

Result type:
Collections$UnmodifiableRandomAccessList
Result value:
[DocumentIssueImpl[issueKey=FOO-0001]]

 What I am looking for, is to iterate over the results and get list URLs.

Thanks in advance :-)  

1 answer

1 accepted

0 votes
Answer accepted
Tomáš Vrabec
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 Leaders.
September 25, 2020

Note to future myself:

It is better and easier to iterate in this way:

def sb_url = []

String query_sb = 'JQL' // edit this query to suit

def query_sb_parsed = jqlQueryParser.parseQuery(query_sb) 

def search_sb = searchService.search(user, query_sb_parsed, PagerFilter.getUnlimitedFilter())

def search_sb_total = ("total: ${search_sb.total}")

SearchService.ParseResult parseResult_sb = searchService.parseQuery(user, query_sb)

if (parseResult_sb.isValid()) {

    def searchResult = searchService.search(user, parseResult_sb.getQuery(), PagerFilter.getUnlimitedFilter())

    def issues = searchResult.results.collect {issueManager.getIssueObject(it.id)}

    for (item in issues) 

  { 

      issue_string = issues.first().toString()

      issue_url = baseurl + issue_string

    sb_url.add(issue_url)

  } 

}    
return sb_url
 

Suggest an answer

Log in or Sign up to answer