Hide section using setSectionDisplay to false failed?

praveenKumar2
Kilo Expert

Hi Developers,

I have written the below script to hide a section with the following code:

function onLoad() {

var sections = g_form.getSectionNames();

if (g_user.isMemberOf('CAB Approval')){

g_form.setSectionDisplay('related_records',true);

}else{

g_form.setSectionDisplay('related_records',false);

}

}

Turns out this script doesn't get executed. Can i know the reason why? when i used g_user.hasRole('inc_viewer'); it worked.

Let me know if i am missing something here...

Thanks,

pK.

1 ACCEPTED SOLUTION

Hi Shloke,

 

I tried this but didn't work, I did a small tuning because I created a form section called "Employee Location" that I want to hide from a group "HR On Boarding". This is the script I used (I did the display BR as you suggested and called it on the script):

function onLoad() {
var sections = g_form.getSectionNames();
if (g_scratchpad.grp == 'true')
{
g_form.setSectionDisplay('Employee Location',false);
}
else{
g_form.setSectionDisplay('Employee Location',true);
}
}

 

Please let me know your thoughts.

Regards Danny

View solution in original post

7 REPLIES 7

Hi Shloke,

 

I tried this but didn't work, I did a small tuning because I created a form section called "Employee Location" that I want to hide from a group "HR On Boarding". This is the script I used (I did the display BR as you suggested and called it on the script):

function onLoad() {
var sections = g_form.getSectionNames();
if (g_scratchpad.grp == 'true')
{
g_form.setSectionDisplay('Employee Location',false);
}
else{
g_form.setSectionDisplay('Employee Location',true);
}
}

 

Please let me know your thoughts.

Regards Danny

Hi 

 

Section name should be in lower case.

eg: if section name is "Hello world" then it should be hello_world.

 

The section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed, for example "Section Four is Here" becomes "section_fourishere". Other non-alphanumeric characters, such as ampersand (&), are removed. Section names can be found by using the getSectionNames() method.

 

Please refer the link below.

Section Name

Hi,

 

As suggested below by Harsh, kindly give the section name as lower case as mentioned below:

 

g_form.setSectionDisplay('employee_location',false);

 

This should work for you. 

 

Cheers,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke