Hide few fields for a specific role based on a condition

Renu9
Tera Contributor

Hi All,

I need to hide few fields on a form based on a condition and also for itil role. I am having 20+ fields on form and need to hide 3 fields.

Those 3 fields should not appear as per reporting purpose.

How can I proceed with this?

1 ACCEPTED SOLUTION

Hi,

you can use field level READ ACLs on those fields and hide those on list view

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

18 REPLIES 18

Yes @Ankur Bawiskar 

Hi Renu, 

ACLs will help you in restricting the fields in the reporting. Kindly select report_view ACL instead of record ACL.

For hiding the field from the form kindly create a onLoad client script with the below code.

if(g_user.hasRole('itil') && "Your condition"){
 
g_form.setDisplay('field1',false); 

g_form.setDisplay('field2',false);

g_form.setDisplay('field3',false);

}

else{

g_form.setDisplay('field1',true);
    
g_form.setDisplay('field2',true);

g_form.setDisplay('field3',true);

}

Regards,

Deepankar Mathur

Ankur Bawiskar
Tera Patron
Tera Patron

@Renu 

since you have 20 fields I won't suggest field level READ ACLs

use onLoad client script and hide those 20 on form

For those 3 fields you can use field level READ ACLs

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

My requirement is reverse actually.

I need to hide 3 fields on the form as per reporting purpose, they contains confidential information.

But the other 20 fields are to be visible by ITIL user.

Instead of writing 20 read ACL's for each field for ITIL user, is there any other option?

Hi,

you can use script for hiding large number of fields

you can use ACL for limited fields

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader