- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 04:53 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2018 04:57 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 05:18 PM
isMemberOf('CAB Approval') method only works on server-side.
please check below thread
isMemberOf function in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 10:04 PM
Hi Praveen,
Use a display business rule to check for the membership condition. Store the boolean result in g_scratchpad. And use the g_scratchpad variable in your onLoad client script.
Darshak

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 11:11 PM
Hi Praveen,
isMemberOf() works at server side. and you had mentioned in client script that's why it will not work.
if you want to use then you must need to use "Glide Ajax" or you can also try with Display Business Rule.
but display business rule will never work on OnChange() you must need to reload the page then it will work.
if you will use onLoad() client Script then display business rule will work perfectly if you will try with glide ajax then in both scenario it will work .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 11:32 PM
Hi,
As mentioned by others above, "ismemberOf()" is a Server Side function and won't work on Client Side. in order to check whether the current Logged in User is a Member of the mentioned Group( "CAB Approval"), you need to use a Display Business Rule and store the Value in a Scratchpad Variable. Once stored you can pass that Scratchpad Variable to the client Side and have your Validations as desired.
For Reference please follow the below steps:
1) Create a Display BR as shown below on the Required Table:
g_scratchpad.grp = gs.getUser().isMemberOf('CAB Approval');
2) Use this Scratchpad Value in your Client Script as below:
Script:
function onLoad() {
var sections = g_form.getSectionNames();
if (g_scratchpad.grp == 'true')
{
g_form.setSectionDisplay('related_records',true);
}
else{
g_form.setSectionDisplay('related_records',false);
}
}
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke