- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 08:05 AM
Hi Team,
I have written below client script in UI page from which I have to send multiple sys_ids to Script Include.
Please see Client script code:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 08:20 AM
@Community Alums Instead of calling the addParam in loop, you should send the comma separated list of sys_ids using the normal GlideAjax call.
function continueOK() {
//Get the selected values from the right slushbucket
alert("You selected Ok");
var values = slushAccounts.getValues(slushAccounts.getRightSelect());
if (values == '') {
alert("At least one group must be selected");
return;
} else {
alert('hello1');
var ajax = new GlideAjax('GetAccountsAjax');
ajax.addParam('sysparm_name', 'accountAdd');
ajax.addParam('sysparm_values', values.toString());
ajax.getXML(addGroupResponse);
}
}
And use .split(',') method in the script include to extract an array of sys_ids in the server side.
e.g.
//Script include
var accountString = this.getParameter('sysparm_values);
var accountArray = accountString.split(','); //Returns an array by spliting the string with ,
for (var i=0; i<accountArray.length;i++){
//do something here
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 08:20 AM
@Community Alums Instead of calling the addParam in loop, you should send the comma separated list of sys_ids using the normal GlideAjax call.
function continueOK() {
//Get the selected values from the right slushbucket
alert("You selected Ok");
var values = slushAccounts.getValues(slushAccounts.getRightSelect());
if (values == '') {
alert("At least one group must be selected");
return;
} else {
alert('hello1');
var ajax = new GlideAjax('GetAccountsAjax');
ajax.addParam('sysparm_name', 'accountAdd');
ajax.addParam('sysparm_values', values.toString());
ajax.getXML(addGroupResponse);
}
}
And use .split(',') method in the script include to extract an array of sys_ids in the server side.
e.g.
//Script include
var accountString = this.getParameter('sysparm_values);
var accountArray = accountString.split(','); //Returns an array by spliting the string with ,
for (var i=0; i<accountArray.length;i++){
//do something here
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 08:20 AM - edited 04-29-2024 08:22 AM
Try changing this line var values = slushAccounts.getValues(slushAccounts.getRightSelect()); to
var values = slushAccounts.getValues(slushAccounts.getRightSelect()).toString().split(',');
Or is might be better wo have your script include to accept the array and process everything at one time instead of calling the script include multiple times.