Show only one option on service field for certain users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 07:32 AM
Good day all
I have a tricky one
on the change form, I have a new field called banking on the drop down(see screenshot directly below), when I am logged in as an ats change user, then only that field should show on the change form. I did like to hide every other option from the dropdown for the ATS users
In other words if a regular user, hide banking from dropdown on service field but if an ATS user, show banking as only option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 07:44 AM - edited 09-28-2023 07:48 AM
Hi @BKennedy
It looks like it is a record in referenced table cmdb_ci_service table.
Write reference qualifier on Service field in change form.
javascript:var query = "name!=Banking"; // or may be you can use "sys_id!=<sys if of banking record>"
/*If user is not memeber of that group
if (!gs.getUser().isMemberOf("Group_name")) {
query;
}
else {
query = "name=Banking";
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 08:00 AM
Thats the thing, I have an existing reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 08:05 AM - edited 09-28-2023 08:26 AM
Hi @BKennedy
Can you try by amending the existing query like below
javascript:
var existingQuery = new global.CMDBCIREIUtils(getBusinessAppsFromService(current.business_service));
var newQuery = existingQuery + "^name!=Banking"; // or may be you can use "sys_id!=<sys if of banking record>"
/*If user is not memeber of that group */
if (!gs.getUser().isMemberOf("Group_name")) {
newQuery;
}else {
newQuery = existingQuery + "^name=Banking";
}
This should work without affecting existing reference qualifier.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 08:04 AM
hello,
You will have to create a script include and call that from the reference qualifier. In the script include you need to add the condition to return the services based on the user's group.
For the script you can refer the below posts:-
https://servicenowguru.com/scripting/script-includes-scripting/advanced-reference-qualifier-script-i...
https://www.servicenow.com/community/developer-forum/call-script-include-from-reference-qualifier/m-...
Please mark my answer as correct based on Impact.