Hide form section based on role

Khalnayak
Tera Guru

Hi guys,

I have created a new tab in our change request form called Lessons Learnt.

Now this tab should only be visible to change_manager role.  

I have created read ACLs for each of the fields in the lessons learnt tab, so only change management can see them.

However, I cannot seem to hide the tab itself, see below.

find_real_file.png

 

please also note, I have also a UI policy which makes the lessons learnt tab only visible when the closure code is unsuccessful or successful with issues.

So although this policy hides the form, but i also need it to stay hidden if the user does not have change_manager role, even if the ui policy is triggered.

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update the UI policy script as this

Execute if true:

function onCondition(){

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

g_form.setSectionDisplay('lessons_learnt', true);

}
else{

g_form.setSectionDisplay('lessons_learnt', false);

}

}

Regards
Ankur

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update the UI policy script as this

Execute if true:

function onCondition(){

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

g_form.setSectionDisplay('lessons_learnt', true);

}
else{

g_form.setSectionDisplay('lessons_learnt', false);

}

}

Regards
Ankur

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

Alp Utku
Mega Sage

Hello,

The sample script is below

 

function onCondition() {

if (g_user.hasRole('change_manager')) { //change the name of the role accordingly

g_form.setSectionDisplay('lessons_learnt', true);
} 

else {
g_form.setSectionDisplay('lessons_learnt', false);
}

}

Anurag Tripathi
Mega Patron
Mega Patron

Your script should work, it should remove the tab and all the fields within it.

Check this out

Show/Hide Form Sections with Multiple Spaces In the Name

-Anurag

-Anurag