- 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
09-01-2021 08:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2021 10:01 PM
Hi Lisa,
Can you please share what you are trying to achieve and share your complete script. Also share what you are getting with above script.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 08:23 AM
Good morning Anil,
On the RITM, we have a List Collector variable where Fulfiller can add Attendee Name to the List Collector.
The code should be checking the List Collector against the approval record to see if the added Attendee Name is one of the existing approver with the state of either "Approved" Or "Requested".
If there is, the code should be remove them from the List Collector.
The below screenshot is from PDI. The company instance has the same setup.
A few months back, you were helping me with the below code and it is working great, because we only have a few users to add. Therefore, we won't run into performance issue.
However, the exiting code only check for state with "Approved". I need to modify to code to also look for state with "Requested".
I have spent many late night trying figure this out, but no luck.
Here is the original code that you shared. Thank you so much Anil.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 09:28 AM
Hi,
Yeah I got it now now.
Please update the line like below:
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 09:35 AM
Also check if you can alter your client script and make use of GlideAjax to get data from server side.
Please mark all appropriate answers as helpful if they help you to to resolve your issue.
Thanks,
Anil Lande
Thanks
Anil Lande