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.

Hiding Form Sections Based on User Group

allison_holt
Giga Expert

I am trying to hide a form section based on a users group, which is not listed on the form itself.

 

I tried the following client script and it's doesn't hide the tab.

 

function on Load(){

var me = g_user.userID();

if (me.isMemberOf('7efcb8956fa21100dd3253eabb3ee40c'){

var sections = g_form.getSections();

sections[3].style.display = 'block';

} else {

    sections[3].style.display = 'none';

    }

}

 

Any help as to what I can do to get this to work would be appreciated!

31 REPLIES 31

Please mark correct/helpful if it has helped you.



Thanks in advance.


still not working. 😞


Hi,



if ((approvalstatus=='Approved' || approvalstatus=='Limit Changed Addressed' || approvalstatus=='Limit Change Finalized') && (person.isMemberOf('T&E Credit Card Team')))


  {


  {sections[1].style.display = 'block';}


  {sections[2].style.display = 'block';}


  alert('checking done');


}


Replace your code with this and see.



Thanks,


Vinitha.K


i will reply you tomorrow morning.



i am leaving for home.


Community Alums
Not applicable

I would do all the checking in the BR and have the BR return true or false.   Then the client script can hide or show based on that.