Unable to retrieve the number value from JSON response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 07:02 AM
Hi,
I am trying to load the data into a table by getting Response body from another instance. Anyhow i am able to get the response, but unable to retrieve the valve. its getting undefined.
response is : {"result":[{"number":"CHG0030779"}]}
script using:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 07:20 AM
@Kumar147 Result Json contains an array of object hence you need to use an index to access individual object. Here is an updated script from my side.
var pagedR = new sn_ws.RESTMessageV2('Change Data', 'Change Request');
var response = pagedR.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var prsData = JSON.parse(responseBody);
gs.log('Test Number: '+prsData.result[0].number); //Access the number property of object at 0th index.
For accessing all the objects in an array you would need to use for or while loop.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 07:27 AM - edited 02-12-2025 07:30 AM
Hello @Sandeep Rajput
Thank you for your response. Response body is so big and contains multiple records. I am actually trying to get all change requests and to load the data into a table. I need the number for the query. How can we get the number value from multiple requests.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 07:28 AM
@Kumar147 Did you try to use
gs.log('Test Number: '+prsData.result[0].number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 08:48 AM
I am able to get the number. but when I am trying to insert the assignment group data, i am getting link instead of assignment group name. how can we overcome that.