- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 09:52 PM
Hello all,
I have created a SCRIPTED RESI API, and when clicked on "Explore REST API" related link from it, and when I give the sys_id of the group and Customer, in the logs it is giving undefined.
So, can you please help me in getting the values as the RITM is also not populating with the reference fields.
Regards,
Lucky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 11:10 PM
sorry but you didn't update the script as per what I shared
now that I know how request body looks, update as this and it will give you the value from JSON
var reqbody = request.body.dataString;
var parsedData = JSON.parse(reqbody);
var companyValue = parsedData.company_CM.toString();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 10:03 PM
how are you sending the json body? share that request body image or JSON here
also use this to parse, line 6 not required
var reqbody = request.body.dataString;
var parsedData = JSON.parse(reqbody);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 10:59 PM
Hello Ankur,
I am currently passing only one reference variable for testing purpose.
But when I open the RITM, in the variables section, the Customer (company_CM) variable is empty.
Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 11:10 PM
sorry but you didn't update the script as per what I shared
now that I know how request body looks, update as this and it will give you the value from JSON
var reqbody = request.body.dataString;
var parsedData = JSON.parse(reqbody);
var companyValue = parsedData.company_CM.toString();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 03:07 AM
Yes, great,
Need to add .toString()
Thanks a lot
Regards,
Lucky