Forums

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

Error on select data for custom picker field

Harald Hiebl October 25, 2025

Hi,

I have configured a csutom picker field for data from ServiceNow, but on loading options I get following error:

Error searching: java.lang.UnsupportedOperationException 

java.lang.UnsupportedOperationException
at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:52) at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:113) at jdk.proxy1/jdk.proxy1.$Proxy5118.isEmpty(Unknown Source)

My code for the field is:

 

HTTPBuilder getHttpBuilder() {
    new HTTPBuilder("https://xxx.com"
    )
}

search = {
    HttpBuilder.request(Method.GET, ContentType.JSON) {
        headers.Accecpt = 'application/json'
        headers."x-sn-apikey" =  "<TOKEN>"
        uri.path = "/api/now/v2/table/cmdb_ci_service_business"
        uri.query = [fields: 'sys_id, name']
    }
}

toOption = { Map<String, String> map, Closure<String> highlight ->  
    new PickerOption(        
        value: map.sys_id,
        label: map.name,    

        html: highlight(map.sys_id, false)
    )
}
Any idea, why the json object can not be converted to a map?

If I create a separate output for the http request, all data are available:

def output = HttpBuilder.request(Method.GET, ContentType.JSON) {
    headers.Accecpt = 'application/json'
    headers."x-sn-apikey" =  "<TOKEN>"

    uri.path = "/api/now/v2/table/cmdb_ci_service_business"
    uri.query = [fields: 'sys_id, name']      

    response.failure = { null }
}
def bsNumber = output["result"]*."number"
def bsName = output["result"]*."name"
def bsSys = output["result"]*."sys_id"

log.info(bsNumber)
log.info(bsName)
log.info(bsSys)
example for one dataset:
[
{
"attested_date": "",
"parent": "",
"operational_status": "7",
"consumer_type": "internal",
"sys_updated_on": "2025-04-28 15:43:02",
"total_vulnerable_items": "",
"u_urgency": "2",
"number": "BSN0002089",
"published_ref": "",
"discovery_source": "",
"first_discovered": "",
"due_in": "",
"used_for": "Production",
"state": "",
"gl_account": "",
"invoice_number": "",
"sys_created_by": "xxxxx",
"warranty_expiration": "",
"vulnerability_risk_score": "",
"owned_by": {
"link": "<LINK>",
"value": "7110acd2eb8a1610e5d8f03dcad0cdee"
},
"checked_out": "",
"sys_domain_path": "/",
"business_unit": "",
"version": "",
"u_description": "<DESCRIPTION>”,maintenance_schedule": "",
"cost_center": "",
"attested_by": "",
"dns_domain": "",
"service_status": "requirements",
"assigned": "",
"life_cycle_stage": "",
"portfolio_status": "pipeline",
"purchase_date": "",
"u_upstream_support_group": "",
"business_need": "",
"delivery_manager": "",
"end_date": "",
"short_description": "<DESCRIPTION>,",
"busines_criticality": "2",
"u_business_contacts": "7110acd2eb8a1610e5d8f03dcad0cdee",
"managed_by": {
"link": "<LINK>",
"value": "763498da4782d210c2fce2d5536d43fc"
},
"stakeholders": "",
"can_print": "false",
"last_discovered": "",
"service_owner_delegate": "",
"sys_class_name": "cmdb_ci_service_business",
"manufacturer": "",
"life_cycle_stage_status": "",
"vendor": "",
"model_number": "",
"u_secondary_routing_group": {
"link": "<LINK>",
"value": "1aff5f883b3a82108368952a85e45a81"
},
"assigned_to": "",
"start_date": "2018-03-29 22:00:00",
"u_billable": "1",
"serial_number": "",
"price_unit": "",
"support_group": {
"link": "<LINK>",
"value": "a96f9fb33bcf8a508733a50c95e45a82"
},
"correlation_id": "",
"unverified": "false",
"attributes": "",
"asset": "",
"u_base_topic": {
"link": "<LINK>"value": "df4b100c3b2d1a108733a50c95e45a28"
},
"skip_sync": "false",
"aliases": "",
"product_instance_id": "",
"u_request_assignment_group": {
"link": "<LINK>",
"value": "a96f9fb33bcf8a508733a50c95e45a82"
},
"attestation_score": "",
"service_level_requirement": "",
"sys_updated_by": "",
"sys_created_on": "2024-11-26 11:23:19",
"sys_domain": {
"link": "<LINK>",
"value": "global"
},
"install_date": "",
"u_meta": "",
"monitoring_requirements": "",
"asset_tag": "",
"user_group": "",
"fqdn": "",
"change_control": {
"link": "<LINK>",
"value": "d566f4daeb6d96108033f1512bd0cdf5"
},
"unit_description": "",
"business_relation_manager": "",
"last_review_date": "",
"u_budget_code": "FCC",
"u_problem_coordinator_group": {
"link": "<LINK>",
"value": "df05bc5aeb6d96108033f1512bd0cdb9"
},
"business_contact": "",
"compatibility_dependencies": "",
"delivery_date": "",
"install_status": "1",
"supported_by": "",
"name": "<NAME>",
"subcategory": "",
"price_model": "per_unit",
"u_tertiary_routing_group": {
"link": "<LINK>",
"value": "549dfc56ebad96108033f1512bd0cdf0"
},
"assignment_group": {
"link": "<LINK>",
"value": "e647781eeb6d96108033f1512bd0cdcf"
},
"managed_by_group": "",
"u_monitoring_routing_group": {
"link": "<LINK>",
"value": "1aff5f883b3a82108368952a85e45a81"
},
"prerequisites": "",
"sys_id": "00a51dea47c25610c2fce2d5536d4345",
"po_number": "",
"checked_in": "",
"sys_class_path": "/!!/!7/!!",
"mac_address": "",
"company": "",
"justification": "",
"department": {
"link": "<LINK>",
"value": "3a3498da4782d210c2fce2d5536d43fc"
},
"checkout": "",
"comments": "",
"cost": "",
"attestation_status": "Not Yet Reviewed",
"sys_mod_count": "1",
"monitor": "false",
"ip_address": "",
"model_id": "",
"duplicate_of": "",
"sys_tags": "",
"u_technical_abbreviation": "fcc",
"cost_cc": "USD",
"order_date": "",
"schedule": "",
"environment": "",
"u_ownership_group": "",
"due": "",
"u_department_lead_service_owner": "",
"attested": "false",
"u_major_incident_commander": {
"link": "<LINK>",
"value": "40753eb13be516508733a50c95e45a60"
},
"u_teamlead_service_owner": {
"link": "<LINK>",
"value": "c8e450de4782d210c2fce2d5536d43e2"
},
"location": "",
"category": "",
"fault_count": "0",
"lease_id": "",
"service_classification": "Business Service"
}
]
 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
October 26, 2025

Hi @Harald Hiebl

From your code, it appears you are trying to invoke an external REST service.

The main problem appears to be that the date is not being parsed correctly into JSON format.

Please refer to the approach provided in this ScriptRunner Example code. It provides a straightforward approach to making GET, POST, PUT, and DELETE requests to external services.

Since you are only making a GET request, you will only need to follow the GET request section of the code.

Let me know how it goes.

Thank you and Kind regards,
Ram

Harald Hiebl October 27, 2025

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

thank you for your tip - fetching data with this script works fine!

final externalUrl = "<URL>"
def getResponse = get(externalUrl, "/api/now/v2/table/cmdb_ci_service_business", "")

if (getResponse) {
   def responseGetMap = getResponse as Map<String, String>

   responseGetMap.each { map ->
      log.info(map.value.getAt('name'))
   }
}


But is it possible to populate the fetched data ('name') to a custom picker field?

with definition:

  • search
  • toOption
  • getItemFromId
  • renderItemViewHtml
  • renderItemTextOnlyValue

or do I have to use another option?

Kind regards,
Harald

DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events