Split function not working in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 07:12 AM
Hello Team,
I tried putting logs and got an error message 'Split function not working'
"org.mozilla.javascript.EcmaError: Cannot find function split in object ".
Script:
answer = [];
SwissTriggerApproval();
function SwissTriggerApproval()
{
var affCIs = new GlideRecord('task_ci');
gs.log('Hello ' +affCIs);
affCIs.addQuery('task', current.sys_id);
affCIs.query();
while(affCIs.next())
{
//answer.push(affCIs.ci_item.u_task);
var list = current.u_watch_list_group;
gs.log('Hello1 ' +list);
var array = list.split(",");
for (var i=0; i < array.length; i++)
{
answer.push(array[i]);
gs.log('Hello2 ' +array[i]);
}
}
}
Error1:
org.mozilla.javascript.EcmaError: Cannot find function split in object .
Caused by error in sys_ui_action.f07eedb3cb200200d71cb9c0c24c9c3d.script at line 14
11: //answer.push(affCIs.ci_item.u_task);
12: var list = current.u_watch_list_group;
13: gs.log('Hello1 ' +list);
==> 14: var array = list.split(",");
15: for (var i=0; i < array.length; i++)
16: {
17: answer.push(array[i]);
Error 2:
org.mozilla.javascript.EcmaError: Cannot find function split in object .
Caused by error in sys_ui_action.f07eedb3cb200200d71cb9c0c24c9c3d.script at line 17
14: var array = list.split(",");
15: for (var i=0; i < array.length; i++)
16: {
==> 17: answer.push(array[i]);
18: gs.log('Hello2 ' +array[i]);
19: }
20: }
org.mozilla.javascript.EcmaError: Cannot find function split in object .
Caused by error in sys_ui_action.f07eedb3cb200200d71cb9c0c24c9c3d.script at line 17
14: var array = list.split(",");
15: for (var i=0; i < array.length; i++)
16: {
==> 17: answer.push(array[i]);
18: gs.log('Hello2 ' +array[i]);
19: }
20: }
PLease provide some inputs so that it can be resolved.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 08:05 AM
Hello Anirudh,
Thanks for the reply but no luck.
Could you please provide the exact code.
May be I am missing something.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 07:26 AM
Hi,
Use and check once.
var array = list.toString().split(',');
Please mark reply as Helpful/Correct, if applicable. Thanks!
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 08:30 AM
Hello Aman,
No luck.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2021 07:40 AM
Hi
which type is the custom field "u_watch_list_group"?
I assume it is a reference field. If so you cannot split that field as basically there is only a sys_id stored in it.
Kind regards
Maik
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 11:22 AM
Hello,
Please check this KB Article
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1275119
Please mark my reply as Helpful and/or Accept Solution, if applicable. Thanks!