How to restrict Virtual Agent to only a specific group/groups?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2024 09:34 PM
Can we make virtual agent icon visible based on user group? I am currently using Out-of-the-box virtual agent chat config. I am checking condition using gs.getUser().isMemberOf(), it is not working as needed. It is making visible to all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 12:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 01:39 AM
Ah clear what you are trying now. And also... no go, so far as I know that's not possible using the server script. For example also try yourself, by only scripting return false or something, the icon will be visible anyway. You can use roles, though scripting logic like this no go as far a I know.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 05:49 AM
Thank you Mark for your response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 02:34 AM
Yes, you can make the Virtual Agent icon visible based on user group. Here's how you can do it:
1. Navigate to the Virtual Agent Designer.
2. Open the chat setup.
3. In the "Client Script" section, you can add a script to check if the user is a member of a specific group.
4. Use the gs.getUser().isMemberOf('group_name') function to check if the user is a member of the group. Replace 'group_name' with the name of your group.
5. If the function returns true, then the user is a member of the group and you can make the Virtual Agent icon visible. If it returns false, then the user is not a member of the group and you can hide the Virtual Agent icon.
Here is a sample code:
javascript
(function() {
var user = gs.getUser();
if(user.isMemberOf('group_name')) {
// code to make the Virtual Agent icon visible
} else {
// code to hide the Virtual Agent icon
}
})();
Please replace 'group_name' with the actual name of your group.
Remember:
- The gs.getUser().isMemberOf('group_name') function checks if the current user is a member of the specified group.
- The function returns true if the user is a member of the group, and false otherwise.
- You can use this function in a client script to control the visibility of the Virtual Agent icon based on the user's group membership.
- Make sure to replace 'group_name' with the actual name of your group.
nowKB.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 02:36 AM
Could you ask your AI thing also where this client script field is? Since that's not on the Agent Chat configuration which is the question here.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field