Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Issue with Split method

naveenbanda
Kilo Contributor

I created a scripted rest api where I'm receiving sys ID's as query parameter

 

var sysID=request.queryParams.sysIDS.split(',');-- if I capturing like this , in logs I could see sysID and typeOf(sysID) is undefined. 
 
If I removed split then it's fine and returning the values.
 
Sys ID which I'm passing : 46edaa6aa9fe198101b9d14ced16619f,46f09e75a9fe198100f4ffd8d366d17b
 
9 REPLIES 9

Bhavya11
Mega Patron

Hi @naveenbanda ,

i have encounter similar issue, when i try to fetch the typeOf(request.queryParams.sysIDS) returned object for me.so .split(',') method didn't work that's  i have change that string then split the value like

var changeId = (request.queryParams.change_id || '') + '';
var sysIDChange = changeId ? changeId.split(',') : [];
 
 
then it worked fine for me. can you try similar way.

Regards
BK
LinkedIn: https://www.linkedin.com/in/bhavyashree-karanth-55032a121
YouTube: https://www.youtube.com/@NowWithBhavya

Thanks Bhavya 

its worked

Hi @naveenbanda .

 

Could you please accept solution and close the thread.

 

 


Regards
BK
LinkedIn: https://www.linkedin.com/in/bhavyashree-karanth-55032a121
YouTube: https://www.youtube.com/@NowWithBhavya

Anurag Tripathi
Giga Patron

Try this

 

var sysID=request.queryParams.sysIDS.toString().split(',');

-Anurag