I am not able to pass array of values in the query parameter, my scripting is working fine with one
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 07:39 PM
var id = ["e99b1e93c3a312103d3e1612b40131a0", "723dda83c327d2103d3e1612b40131ca"];
// Join the ID array into a string with commas
var idParam = id.join(',');
// Construct the query parameters with the IN operator
var queryParams = {
"sys_idIN": idParam
};
var tmfServiceOrderAPIUtil = new sn_ind_tmt_orm.TMFServiceOrderGetAPIUtil();
// Make sure to modify the URL if needed (e.g., adding any required query params)
var response = tmfServiceOrderAPIUtil.processListServiceOrder(queryParams, 'https://dev186817.service-now.com/api/sn_ind_tmt_orm/serviceorder');
var statusCode = response.status;
var responseBody = JSON.stringify(response.details);
if (statusCode == 200) {
gs.info("Request succeeded, response: " + responseBody);
} else {
gs.error("Request failed with status code: " + statusCode + " and message: " + responseBody);
}
=============================================================
var id = ["e99b1e93c3a312103d3e1612b40131a0", "723dda83c327d2103d3e1612b40131ca"];
var queryParams = {
"id": id
};
var tmfServiceOrderAPIUtil = new sn_ind_tmt_orm.TMFServiceOrderGetAPIUtil();
var response = tmfServiceOrderAPIUtil.processListServiceOrder(queryParams, 'https://dev186817.service-now.com/api/sn_ind_tmt_orm/serviceorder');
var statusCode = response.status;
var responseBody = JSON.stringify(response.details);
if (statusCode == 200) {
gs.info("Request succeeded, response: " + responseBody);
} else {
gs.error("Request failed with status code: " + statusCode + " and message: " + responseBody);
}
==================================================
Following error i am getting when i use the above code, from the rest API explorer i don't find the option to construct the above one and test. Can some one help me
Request failed with status code: 404 and message: {"code":60,"reason":"Resource not found","message":"No Record found for given filter criteria","details":[{"message":"No Record found for given filter criteria","datapath":""}]}
10 REPLIES 10
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 04:25 AM
Hi @ahmed786
It seems you are missing "sys_idIN" in the query. Try the below script.
var id = ["e99b1e93c3a312103d3e1612b40131a0", "723dda83c327d2103d3e1612b40131ca"];
// Join the ID array into a string with commas
var idParam = id.join(',');
// Construct the query parameters with the IN operator
var queryParams = {
"query": "sys_idIN"+idParam
};
gs.info(queryParams.query);