Unable to hide sections using setSectionDisplay()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2021 10:25 PM
Requirement was to hide sections based on role 'xyz' & 'assigned_to' is the current user.
I wrote display business rule to validate above condition and saved in scratchpad as below:
if ((gs.getUserID() == current.assigned_to) || (gs.hasRole('xyz')) ) {
g_scratchpad.user = true;
}
else {
g_scratchpaduser = false;
}
And called in the onload client script as below:
if (g_scratchpad.user == 'false') {
g_form.setMandatory('mandatory', false); // tried using this to remove all mandatory fields on all sections
g_form.setSectionDisplay('section1', false );
g_form.setSectionDisplay('section2', false);
g_form.setSectionDisplay('section3', false);
g_form.setSectionDisplay('section4', false);
g_form.setSectionDisplay('section5', false);
} else {
g_form.setSectionDisplay('section1', true);
g_form.setSectionDisplay('section2', true);
g_form.setSectionDisplay('section3', true);
g_form.setSectionDisplay('section4', true);
g_form.setSectionDisplay('section5', true);
}
setSectionDisplay() not working .. also tried setDisplay() not working.
Verified section names ex: section_detail all correct. Please correct me anywhere i have done any mistake?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2021 10:30 PM
Hi
As per your script provided in else part scratchpad is not properly set. Please check that once and see if it works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2021 10:37 PM
I also tried adding - else if (g_scratchpad.user == 'true'{
alert('dont hide for me');
g_form.setSectionDisplay('section1', true);
g_form.setSectionDisplay('section2', true);
g_form.setSectionDisplay('section3', true);
g_form.setSectionDisplay('section4', true);
g_form.setSectionDisplay('section5', true);
}
not working. when I put an alert and check, I'm able to get the alert properly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2021 10:34 PM
Hi,
Change this line
g_scratchpaduser = false;
to
g_scratchpad.user = false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2021 10:39 PM
sorry it was typo error, g_scratchpad.user = false;