
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 06:17 AM
UI Page (sample) data: infoArray[tabName].length is 10590
var mainDataArray = [];
for (var i = 0; i < infoArray[tabName].length; i++)
{
mainDataArray.push({
'Supplier Name':infoArray[tabName][i]['Supplier Name'],
'Invoice Number':infoArray[tabName][i]['Invoice Number'],
'Invoice Amount':infoArray[tabName][i]['Invoice Amount'],
'Payment Method':infoArray[tabName][i]['Payment Method'],
'Check Number':infoArray[tabName][i]['Check Number'],
'Check Date':infoArray[tabName][i]['Check Date'],
'Accounting Date':infoArray[tabName][i]['Accounting Date'],
'Check Amount':infoArray[tabName][i]['Check Amount'],
});
}
var ga = new GlideAjax('glideAjax_CheckRequest_processPayments');
ga.addParam('sysparm_name', 'processData');
ga.addParam('sysparm_array', mainDataArray);
ga.getXML(_parseGlideAjaxAnswer_check_request_import_excel_payments);
Cool, at this point, the mainDataArray array has a length of 10590... so far so good.
Script Include:
var glideAjax_CheckRequest_processPayments = Class.create();
glideAjax_CheckRequest_processPayments.prototype = Object.extendsObject(AbstractAjaxProcessor, {
processData: function()
{
var importedArray = this.getParameter('sysparm_array');
var ary = new JSON().decode(importedArray);
gs.log("*** ary.length: " + ary.length);
for (var i = 0; i < ary.length; i++)
{
gs.log("*** in: " + ary[i]['Invoice Number']);
}
return ary.length;
}
});
The gs.log("*** ary.length: " + ary.length); comes out to be 2
I've done some JSON.parse'ing and other gs.log stuff to determine that my issue is the fact this is a multidimentional array.
I'm not a JSON guy so can a JS/JSON gruru kindly instruct me what code I need to change to get the Script Include's for() loop to work the way I have it depicted?
Thanks! (this proves I'm not the code-jedi I thought I was... lol)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 07:33 AM
HI
I don't think you can pass your "mainDataArray" array directly as a parameter to the AJAX call.
You need to convert this to a json string first, so change it to
ga.addParam('sysparm_array', JSON.stringify(mainDataArray));
And then in your script include you convert it back again
var ary = JSON.parse(importedArray);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 07:33 AM
HI
I don't think you can pass your "mainDataArray" array directly as a parameter to the AJAX call.
You need to convert this to a json string first, so change it to
ga.addParam('sysparm_array', JSON.stringify(mainDataArray));
And then in your script include you convert it back again
var ary = JSON.parse(importedArray);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 04:59 AM
Well... it appears as if ServiceNow has a limit on the size of data you can send as an ajax parameter.
I get this error:
And when I click on it...
And when I click on the js_includes link:
For testing purposes, I limited the mainDataArray to a sample of 5 objects (instead of 10,800), and used your method which worked perfectly! So, your answer is correct and I will mark it as such, but I need to know if this size limitation is on the ServiceNow end or my browser end?
I'm trying to pass this:
So trying to pass 2.4 million text characters as a string to a Script Include fails.
Again, I ask, is this size limitation is on the ServiceNow end or my browser end?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 05:34 AM
The POST limit depends on the webserver.
In apache tomcat this is 2 MB if ServiceNow has not configured it otherwise. tomcat - Is there a max size for POST parameter content? - Stack Overflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 05:38 AM
Thank you so much. I'll open an incident with HI and see what our instance server setting is, and if they can raise it.
Again, thank you Lars for all the excellent info!