Display only selected group users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:02 AM
Hi Team,
I have two fields in incident table,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:22 AM
I assume you are populating Service Group before displaying the list of Service Users. With your custom table you'll have to add some logs to see why it isn't working. Put one at the beginning of the function to confirm it is running, and the value of groupId passed in from the form. Add another inside the while loop so you can see if any records are returned. Is your custom table available to all application scopes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:22 AM - edited 10-21-2024 06:24 AM
Hi @AnilM99
I noticed a small correction needed in your code. The line should be gr.query().
Here’s the full corrected code:
getMembers: function(groupId) {
var id = [];
var gr = new GlideRecord('u_service_user_grmember');
gr.addQuery("u_service_group", groupId);
gr.query(); // Correctly call query method
while (gr.next()) {
id.push(gr.getValue("u_user"));
}
return "sys_idIN" + id.join(',');
},
Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution
Thanks
Esh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:30 AM - edited 10-21-2024 07:06 AM
* You should call the Script Include as it is in the API Name: "new x_something.getUserMembers().getMembers(current.u_service_group)."
* you should call the query method properly: "gr.query(); "
* Also, check if the Script Include is accessible from the specified scope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:47 AM - edited 10-21-2024 06:51 AM
Hi @AnilM99 ,
Please check your reference qualifier to see how you’re calling it (the round brackets are missing when writing the ScriptInclude Name under the reference qualifier field).
You should write it in the following way:
Reference qual: javascript: new getUserMembers().getMembers(current.u_service_group);
And please write your script include function like that -
getMembers: function(groupId) {
var id = [];
var gr = new GlideRecord('u_service_user_grmember');
gr.addQuery("u_service_group", groupId);
gr.query();
while (gr.next()) {
id.push(gr.getValue("u_user"));
}
return "sys_idIN" + id.join(',');
},
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.
Thank you!
Moin Kazi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~