- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2017 09:30 AM
Hi. I'm trying to hide a form section on the user table unless the user has a role or the it's the users record. I've got the first part working with the following Client Script but I don't know how to configure it so the user can see the record if it's theirs. Can anyone else?
function onLoad() {
if (g_user.hasRole('secret_qa_viewer')) {
g_form.setSectionDisplay('security_questions', true);
}
else{
g_form.setSectionDisplay('security_questions', false);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 04:41 AM
Okay, I managed to get it working! Here's the code:
function onLoad() {
var id = (g_form.getUniqueValue());
if (g_user.userID == id || g_user.hasRole('secret_qa_viewer')) {
g_form.setSectionDisplay('security_questions', true);
}
else{
g_form.setSectionDisplay('security_questions', false);
}
}
Thanks everyone who replied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2017 09:37 AM
Hi Wayne,
It sounds like below threads, So Please Refer
Hiding Form Sections Based on User Group
Hide/Show Form Section Based on role
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2017 09:39 AM
Please note that simply hiding a field via client script is not true security; if this is sensitive information I would ensure to also add a ACL record for read access to the actual fields, based on the same conditions you described (secret_qa_viewer role OR caller is javascript:gs.getUserID();)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 04:11 AM
Thanks, I do have ACLs in place. However, that doesn't stop the section being visible which is my requirement here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2017 09:40 AM
Please update your client script like below
var user = g_form.getReference('assigned_to'); // modify to check record created by
- if (g_user.hasRole('secret_qa_viewer')) {
- g_form.setSectionDisplay('security_questions', true);
- }
if(g_user.userID == user.sys_id){
g_form.setSectionDisplay('security_questions', true);
}
- else{
- g_form.setSectionDisplay('security_questions', false);
- }