Show choices based on the assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 10:37 AM
Hello team,
I have a requirement where I need to make certain choices from a dropdown field available to only certain groups. For eg: The time card, indirect tax and resource planning options should be available only to the finance team. can we do this using UI policies or client scripting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 11:08 AM
Hi @RohanDS ,
Is it a reference field
Then I suggest you to user advanced reference qualifier.
Regards
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 11:12 AM
Hello Harshal,
It is not a reference field. Its a select box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 11:50 AM - edited 08-10-2023 11:51 AM
Hi @RohanDS ,
Hope you are doing great.
yes you can do it via UI Policy too ,
In advance tab you can write a script to set choices to be displayed in True section.
Configure a UI Policy:
- Go to the "UI Policy" table in ServiceNow.
- Create a new UI Policy or edit an existing one depending on your needs.
- Set the "Table" field to the table where the dropdown field is located.
- Define the condition to check if the user belongs to the "Finance Team" group.
- Choose the field (dropdown) you want to control, and set its "Visibility" to "Visible" when the condition is met.
Specify Choices: If the choices in the dropdown field are dynamically generated, you can set the visibility of each choice using a script. If the choices are static, you can handle this in the UI Policy condition directly.
PFB reference script for same :
// Check if the user belongs to the "Finance Team" group
var isFinanceTeam = gs.getUser().isMemberOf('Finance Team');
// Replace 'financeOption' with the actual value of the Finance option in the dropdown
var financeOption = 'time_card';
// If the user is part of the Finance Team, make the finance option visible
isFinanceTeam && current.variable_name == financeOption
But as per good practice in servicenow , we should be avoid using script in UI policy , so you can generate your script logic in client script.
Regards,
Riya Verma