- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 09:24 AM
Hello I've been struggling with trying to populate a list collection of all the groups the user is in based on what user is selected in a reference variable. here is my code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var userRefField = g_form.getReference('user', onUserRefLoaded);
function onUserRefLoaded(userRef) {
if (!userRef) {
return;
}
var groupList = userRef.getMyGroups();
var groupArray = [];
while(groupList.next()) {
var groupName = groupList.name;
groupArray.push(groupName);
}
var lc = g_form.getControl('groups');
lc.clearOptions();
for (var i = 0; i < groupArray.length; i++) {
lc.addOption(groupArray[i], groupArray[i], i);
}
}
}
It runs onChange of the user reference variable.
The goal is to basically have the groups populate based on the user added but I cant seem to get it working
Any assistance would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 11:05 AM
I was able to solve this issue with the use of this post: https://www.servicenow.com/community/itsm-forum/get-all-groups-user-is-a-member-of-based-off-of-a-ca...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 10:09 AM
Hi @dagarson ,
Please use GlideAjax instead of getReference.
Refer this link:
Extending GlideAjax | ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 11:05 AM
I was able to solve this issue with the use of this post: https://www.servicenow.com/community/itsm-forum/get-all-groups-user-is-a-member-of-based-off-of-a-ca...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 11:11 AM
Hi @dagarson ,
ServiceNow won't suggest GlideRecord in Client side scripting better you use same GlideRecord in Script include and call it from client script.