- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 10:44 PM
Hello,
I have a List Collector variable on the RITM.
Users can select name from the List Collector. If selected name listed as an approver and state is approved, display a message and remove the name from the List Collector. I appreciate the help.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2021 09:33 AM
Make sure you have checked 'Applies to a Requested Item'.
You can use below logic in your client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var RITM = g_form.getUniqueValue();
var myList = newValue;
var myArray = myList.split(',');
var result = [];
for (var i = 0; i < myArray.length; i++) {
var sysapproval = new GlideRecord('sysapproval_approver');
sysapproval.addQuery('sysapproval', RITM);
sysapproval.addQuery('approver', myArray[i].toString());
sysapproval.addQuery('state', 'approved');
sysapproval.query();
if (!sysapproval.next()) {
result.push(myArray[i].toString());
}
}
if (myArray.toString() != result.toString()) { // to avoid reccusrsive calls
g_form.setValue('attendeeName', result.toString());
}
}
With this script you will observer some performance issue if add more users from list.
I would suggest to use GlideAjax and get the result from server. It would be more efficient.
Pleas find below Ho you can use GlideAjax:
Pass myList and RITM id as parameters to and use below part of client script in Script include to get result:
var myArray = myList.split(',');
var result = [];
for (var i = 0; i < myArray.length; i++) {
var sysapproval = new GlideRecord('sysapproval_approver');
sysapproval.addQuery('sysapproval', RITM);
sysapproval.addQuery('approver', myArray[i].toString());
sysapproval.addQuery('state', 'approved');
sysapproval.query();
if (!sysapproval.next()) {
result.push(myArray[i].toString());
}
}
I don't mine sharing complete script, but that would server the purpose only. I would be more happy if you try it by yourself. It would be useful in future as well. Happy Learning 🙂
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2021 09:13 AM
Good morning Anil,
Thank you so much for your advice! I will keep searching for answer in the community if I need help in the near future.
I have tried to understand what your script is doing, but I only can understand part of what it is doing, because I'm weak at coding skill.
One last question to this issue. After the program ran, I would like to displays a message with selected name.
I added alert, but it only displays numbers instead of the attendee name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2021 09:26 AM
This is because in backend ListCollector variable store sys_id of reference table records.
And we have converted that comma separated list into an array.
If you change this code to GlideAjax then you can use more serverSide Api to get name of users using dot Walking. and return result of removed user names.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2021 09:14 PM
I will try out in Glide Ajax. Thank you for your effort and time!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2021 12:04 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2021 12:15 AM
Hi,
You can do it by two ways:
1.
var sysapproval = new GlideRecord('sysapproval_approver');
sysapproval.addQuery('sysapproval', RITM);
sysapproval.addQuery('approver', myArray[i].toString());
sysapproval.addQuery('state', 'approved').addOrCondition('state','requested');
sysapproval.query();
2.
var sysapproval = new GlideRecord('sysapproval_approver');
sysapproval.addQuery('sysapproval', RITM);
sysapproval.addQuery('approver', myArray[i].toString());
var Q1 = sysapproval.addQuery('state', 'approved');
Q1.addOrCondition('state','requested');
sysapproval.query();
In both cases result will be same:
Thanks,
Anil Lande
Thanks
Anil Lande