Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
String index out of range exception with an inbound JSON call - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • String index out of range exception with an inbound JSON call
KB0725882

String index out of range exception with an inbound JSON call


2554 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Symptoms


When performing the below inbound call on JSON API from browser on the incident table, we see an error with the exception -

"{"reason":null,"error":"String index out of range: -10"}" and the incident records were not retrieved in the browser results

 

 Inbound API Call:

https://<instance name> .service-now.com/incident.do?JSONv2&sysparm_action=getRecords&sysparm_query=active=true&displayvalue=true

 

Exception in the browser with the above Inbound call:

 

Release


Issue reported on Kingston Patch 12 but the exception is irrelevant of the product version. It can trigger on any version if the table field types were not configured correctly

 

Cause


  • There exists a custom field named "xxxxx" on the task table which is of type counter for which the expected values should be date/time values.
  • It is observed that the values for this field on the task table ranges between 0 and 17 which are of type Integer. The platform code is expecting this to be a date/time value and does a substring starting at position 11.
  • Since the current integer values which you've got for this field were less than 11 characters( Not the Date/Time Values), you see an "String index out of range" exception when tried to query the incident table using JSON API 

 

Resolution


The solution is to change the type of above mentioned  "xxxxx" custom field on task table from "counter" to "integer string" and then run the JSON call. This should retrieve the incident records in the browser results successfully.


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.