Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

hide fields on workspace form for all members of assignment group

Community Alums
Not applicable

Hi ,

I am trying to hide few fields for an entire assignment group.

How can I achieve this?

 

Thanks in advance!

8 REPLIES 8

aryanjain25
Giga Guru

Hi @Community Alums ,

 You can try to use client script to perform the task.

 

Try the following code:

function onLoad() {
    // Get the assignment group
    var assignmentGroup = g_form.getValue('assignment_group');
    
    // Check if the group is the one you want to hide fields for
    if (assignmentGroup == 'YOUR_ASSIGNMENT_GROUP_ID') {
        // Hide fields
        g_form.setDisplay('field_name_1', false);
        g_form.setDisplay('field_name_2', false);
    }
}

 

Please mark this response as correct or helpful if it helped you with your question.

 

Thanks,

Aryan Jain

Community Alums
Not applicable

hi,

 I tried this script 

function onLoad() {
    // Get the assignment group
    var assignmentGroup = g_form.getValue('assignment_group');
   
    // Check if the group is the one you want to hide fields for
    if (assignmentGroup == '8e6c34733bacd2103d955d1c95e45af3') {
        // Hide fields
        g_form.setDisplay('opened_at', false);
        g_form.setDisplay('u_type_of_user', false);
    }
}.Also I changed scope to workspace while creating client script.
I impersonated user who is member of this group,still fields are visible to him on worksapce form

Hi @Community Alums Try to achieve this using UI Policy. Is there any specific reason you are trying client script?

Community Alums
Not applicable

I tried creating UI policy with scope as workspace. In table its showing blank.

Thats why I opted client script,

Now I created UI Policy withs scope as global.table as sn_sm_finance _request.

when to apply- user is pablo

I selected view as workspace as I want to hide field for pablo on workspace form.

Still opened at field is visible for pablo on workspace form.

PFA for reference