- 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-08-2021 11:00 PM
Hi,
An RITM will have variables which are filled on Catalog Item form. At that time the approval is not exist. So it is not possible to check selected user with the approvers.
If user is able to edit variable after RITM is generated the you can use onChange Catalog Client script and check 'Applies to a Requested Item' checkbox.
OnChange of list collector field make a GlideAjax call and in script include glide to Approval table and look for related approvals. If selected user is one of approver then remove that sys_id from array and return updated array. and set it to the field in client script.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 11:38 PM
Hi Anil,
The comparison is after RITM is approved, I need to check the approver name again the list collector.
Based on your suggestion, it is very complicated. I don't where to begin. Could you please provide screenshots or samples so I can use it as a guide. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2021 11:44 PM
Why to remove that user from list collector variable once RITM is approved by that user?
You should not remove/delete any data from any variable post RITM is created as it would lead to data discrepancy and would result in data loss.
Please check this with your business team on the requirement
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2021 09:29 AM
Ankur,
When approved RITM loaded, the list collector variable is empty.
Fulfiller can select the name from the list collector. At this stage, the list collector data has not been saved to the database.
The program should be checking to see if the selected name is one of the approver. if it is, remove the name from the list collector.
This is an Union special event and management is this case is Approvers are not allow to the event