- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:27 AM
I need to remove certain options from a dropdown field based on whether the current user is a member of a "Database application support" group that we have in our service now instance, but i cannot use the following
if (gs.getUser().isMemberOf('Database Application Support')) {
}else{
}
The object "gs" should not be used in client scripts.
How can I check if the user is a member of this group?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:33 AM
Since gs is server side script, you can't use it in client script.
There are two options.
1st one is to create a client callable script include and call the script from client script using glideajax.
The other option is create a new role and assign to Database Application Support.
Then in client script you can check if (g_user.hasRoleExactly('your_new_role'))
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:33 AM
Since gs is server side script, you can't use it in client script.
There are two options.
1st one is to create a client callable script include and call the script from client script using glideajax.
The other option is create a new role and assign to Database Application Support.
Then in client script you can check if (g_user.hasRoleExactly('your_new_role'))
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019 10:59 AM
Thanks creating and checking for the new role from a client script works

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:36 AM
Hi,
You have to run this at the server side. You can do the glideajax and pass the parameters to get the output. The other option is to create a display business rule and store the output in scratchpad and then validate it at the client side.
GlideAjax approach: https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference/r_GlideAjax.html
Scratchpad approach: https://docs.servicenow.com/bundle/london-application-development/page/script/business-rules/concept/c_ScriptingWithDisplayBusinessRules.html
-Pradeep Sharma