- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 12:26 AM - edited 07-10-2023 01:31 AM
Hi Team ,
Am using scoped application(x_cenv_integration) and written inbound with pagination
URL:https://xyz.service-now.com/api/x_cenv_integration/oas_sr?size=2&number=1
inboundCode:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 06:41 AM
then this line is the issue
if (grRequestedItem.variables.hasOwnProperty(prop)) {
try changing as this
var toDelete = ['new_location_details', 'requester_details', 'request_details'];
var pageSize = request.queryParams.size;
var pageNumber = request.queryParams.number;
var pageRecords = [];
var grRequestedItem = new GlideRecord('sc_req_item');
grRequestedItem.orderByDesc('sys_created_on');
grRequestedItem.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('2023-07-01','00:00:00')^sys_created_on<=javascript:gs.dateGenerate('2023-07-07','23:59:59')");
grRequestedItem.chooseWindow(pageSize * (pageNumber - 1), pageSize * pageNumber);
grRequestedItem.query();
while (grRequestedItem.next()) {
var resJSON = {
number: grRequestedItem.getValue('number'),
cat_item: grRequestedItem.getValue('cat_item'),
contact_type: grRequestedItem.getValue('contact_type'),
state: grRequestedItem.getValue('state')
};
for (var prop in grRequestedItem.variables) {
gs.info("check inside for" + prop) ;
if (grRequestedItem.variables[prop] != '') {
gs.info("check inside if");
if (!toDelete.includes(prop)) {
var variable = grRequestedItem.variables[prop].getValue();
resJSON[prop] = variable;
}
}
}
pageRecords.push(resJSON);
}
response.setBody(pageRecords);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 01:57 AM
which line is that?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 02:29 AM
Hi @Ankur Bawiskar am not using type IdFunctionObject in my code ,but still it throws an error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 03:11 AM
that's correct but definitely due to some line your script it's throwing the error
try adding gs.info() and check till where it's working fine
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 05:52 AM - edited 07-10-2023 05:53 AM
code is not going to if condition in below highlighted