Show choices based on the assignment group

RohanDS
Tera Contributor

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?

RohanDS_0-1691688957420.png

 

3 REPLIES 3

Harshal Aditya
Mega Sage
Mega Sage

Hi @RohanDS ,

 

Is it a reference field 

Then I suggest you to user advanced reference qualifier.

 

Regards

Harshal

Hello Harshal,

 

It is not a reference field. Its a select box.

Riya Verma
Kilo Sage
Kilo Sage

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.

  1. 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.
  2. 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.

 
 
 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma