Issue with Split method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2026 12:28 AM
I created a scripted rest api where I'm receiving sys ID's as query parameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2026 03:15 AM - edited 01-23-2026 08:48 PM
var param = request.queryParams;
var sysID = (param.sysIDS) ? param.sysIDS : '';
if(sysID && sysID!=''){
var sysIDArr = String(sysID).split(",")
}Try the above code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2026 04:12 AM
Hello @naveenbanda ,
I would recommend don't directly call .split(',') — check the type first. Your framework may already be parsing comma-separated query params into arrays.
var sysIDS = request.queryParams.sysIDS;
var sysID;
if (typeof sysIDS === 'string') {
sysID = sysIDS.split(',');
} else if (Array.isArray(sysIDS)) {
sysID = sysIDS;
} else {
sysID = [];
}
gs.info('sysID: ' + sysID);
If my response helped mark as helpful and accept the solution..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2026 04:21 AM
Hi @naveenbanda ,
I would suggest not calling .split(',') directly. First check the data type.In some cases, the framework already converts comma-separated query parameters into an array.
var sysIDS = request.queryParams.sysIDS;
var sysID;
if (typeof sysIDS === 'string') {
sysID = sysIDS.split(',');
} else if (Array.isArray(sysIDS)) {
sysID = sysIDS;
} else {
sysID = [];
}
gs.info('sysID: ' + sysID);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2026 04:42 AM
@Anurag Tripathi has the best approach, amidst a lot of unnecessary approaches. You are trying to execute a string method - .split() - on a value that is not a string, as evidenced by your typeOf log, so just force the value to a string before you split and you'll be fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2026 06:11 AM
Thanks @Brad Bowman

