Can we hide a section on a form based on roles through ACL?

micky09
Tera Contributor

Can we hide a section on a form based on roles through ACL?

4 REPLIES 4

Ravi T
Tera Guru

Hi Micky,

You can write a client script to acheive this

use the below code in the script

 

if(g_user.hasRole(''))// add the role

{

g_form.setSectionDispaly('  ',true/false); //add your section name 

}

 

Regards

Ravindra

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Micky,

you can use onLoad client script and based on whether logged in user has role hide the section

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Bhagya Lakshmi
Mega Guru

Hello,

As of I know this can be possible by onLoad client script. You can write onLoad client script and based on required roles you can show/hide sections.

Eswar11
Mega Contributor

Try this on form load.

var sections = g_form.getSections();

if (g_user.hasRole('RoleName')) {

        g_form.setSectionDisplay(sections[1], false);

}

else{

      g_form.setSectionDisplay(sections[1], true);

}