Forums

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

How to show all results when converting the field using (End Point)

Fernando Passos
Contributor
August 10, 2021

Hi Guys.

I have a problem can you help me please? 

I have a field that returns the result of a service (End Point). However, it does not return all 37,065 results and does not work out complete in field conversion. what did I do wrong?

Conversion:

getFieldByName("Orgão").convertToMultiSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom",
query: true,
minQueryLength: 2,
keyInputPeriod: 500,
formatResponse: "general",
]
])

Result: In the image below I can only get the result up to (C) and there is no link to show the rest and the autocomplete does not work.

Thanks.

image.png

1 answer

1 accepted

0 votes
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
August 11, 2021

Hi @Fernando Passos can you share source code or you REST API endpoint /rest/scriptrunner/latest/custom?

Fernando Passos
Contributor
August 12, 2021 edited

Hi @Martin Bayer _MoroSystems_ s_r_o__ , yes of course follow.

Thanks. 

image.png

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate

import groovy.json.JsonBuilder

import groovy.transform.BaseScript

import groovyx.net.http.ContentType

import groovyx.net.http.HTTPBuilder

import groovyx.net.http.Method

import javax.ws.rs.core.MultivaluedMap

import javax.ws.rs.core.Response

import org.apache.log4j.Logger

import org.apache.log4j.Level

  

def log = Logger.getLogger("com.localhost.getlistaRestricaoQuery")

log.setLevel(Level.DEBUG)

 

@BaseScript CustomEndpointDelegate delegate

 

getlistaRestricaoQuery(httpMethod: "GET") { MultivaluedMap queryParams ->;

 

    def rt = [:]

        def httpBuilder = new HTTPBuilder(“URL”)

        def repos = httpBuilder.request(Method.GET, ContentType.JSON) {

            uri.path = “URL”

            headers."User-Agent" = "My JIRA"

 

             response.failure = { reader;

                 log.warn("Failed to query getlistaRestricao: " + reader.text)

             }

        }

        //def repoNames = repos["value"]*."name"

        def repoNames = repos["items"]*."value"

       //def repoNames = repos*."value"                                  

        log.debug "data from getlistaRestricaoQuery:"+repoNames                                                                  

        rt = [

            items: repoNames.collect { String repo ->

                [

                    value: repo,

                     html: repo,

                    label: repo,

                ]

            },

            total: repoNames.size(),

            footer: "Escolha o Orgão... (apresentando 1 de ${repoNames.size()} ...)"

        ] 

    return Response.ok(new JsonBuilder(rt).toString()).build();

}

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
August 12, 2021

Ok, I think the URL in your behaviours should be set to

  •  /rest/scriptrunner/latest/custom/getlistaRestricaoQuery

And you need to get query parameter value

  • def query = queryParams.getFirst("query") as String

... then you can use query when calling your httpBuilder request if your endpoing "URL" accepts query to filter results, otherwise you need to filter results (repoNames) using query property.

Fernando Passos
Contributor
August 12, 2021

I hid my original url is this one.

def rt = [:]
def httpBuilder = new HTTPBuilder("https://servicos-int.lista.com.br")
def repos = httpBuilder.request(Method.GET, ContentType.JSON) {
uri.path = "/Backoffice/inst/PLD/rest/getlista/43"
headers."User-Agent" = "My JIRA"

Reading the service works perfectly, the problem is in the visualization it is only showing the first five thousand items on the list. The other items on the list are hidden.

for example:

image.png

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
August 13, 2021 edited

Ok, so you load all the values on the beginning, right? And you expect filtering of values already loaded in the field.

I think you should ask Adaptavist because I didn't find anything in the documentation what describes max size of collection in the dropdown.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events