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

dmathur09
Kilo Sage
Kilo Sage

Hi Renu,

You need to create 3 read ACL on the mentioned field and put the relevant condition and provide ITIL role in the role section.

Regards,

Deepankar Mathur

Renu9
Tera Contributor
Hi Deepankar, I need to hide those 3 fields and to display rest other.

Hi Renu,

You can use the onLoad client script

var isITIL= g_user.hasRole('itil');

if(your_condition && isITIL){

g_form.setMandatory('field1',false);    //if your field is mandatory

g_form.setDisplay('field1',false);

g_form.setMandatory('field2',false);    //if your field is mandatory

g_form.setDisplay('field2',false);

g_form.setMandatory('field3',false);    //if your field is mandatory

g_form.setDisplay('field3',false);

}

else{

g_form.setMandatory('field1',true);    //if your field is mandatory

g_form.setDisplay('field1',true);

g_form.setMandatory('field2',true);    //if your field is mandatory

g_form.setDisplay('field2',true);

g_form.setMandatory('field3',true);    //if your field is mandatory

g_form.setDisplay('field3',true);

}

@Rahul Dev 

Can you mark my response as correct to your earlier question?

You have marked my response as helpful for it.

How to set a default value for choice field based on another choice field using configure dictionar...

Regards
Ankur

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