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.

Preferences Section on Project form is Visible after creating UI policy

saurabha_upare
Tera Contributor

On the project form I have Created UI policy with following script

 

g_form.setDisplaySection('score');

g_form.setDisplaySection('business_case');

g_form.setDisplaySection('preferences');

 

With help of this UI policy Score and Business case section got hidden but not the Preferences section.

 

why? 

 

3 REPLIES 3

Simran Gadodiya
Mega Sage

Hello @saurabha_upare 

Try with complete syntax mentioned below.

g_form.setSectionDisplay('<section_name>', false);

 Hope this helps you. Please mark it as helpful and accept the answer it it works for you.

Thanks.

harinivenkatesh
Tera Contributor

Hi I have the below script in place and yet it does not work in my client as well as pdi. 

function onLoad() {
// Type appropriate comment here, and begin script below
if (g_user.hasRole('admin') || g_user.hasRole('it_pps_admin')) {
// User has required role, do nothing
return;
}

// Hide the Preferences section for all others
alert(g_form.getSectionNames());
g_form.setSectionDisplay('preferences', false);
g_form.setSectionDisplay('dates', false);
}
 
Dates tab is getting hidden. In my alert, the value returned for preferences tab is same as in the code. I have tried the same single line of sectiondisplay in ui policy scripts and it still doesnt apply. 

harinivenkatesh
Tera Contributor