Hiding the Attachments user now member of current assignment group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 05:10 AM
Hi,
I am trying to achieve a requirement where i want to hide all attachments attached in the form if the the current logged in user is not member of current assignment group. i tried this through ACL but no luck.
NOTE: i trying to achieve this on scoped app.
Regards
Yadvinder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 05:21 AM
Hi @yadi , You can try the following script in client script (Uncheck 'isolate script' field).
gel('header_attachment').style.display='none';
Even in that case, the attachments may be visible in the activities if the user has the required role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 05:24 AM
you can use display business rule and onLoad client script
Business Rule:
(function executeRule(current, previous /*null when async*/) {
// Check if the current user is a member of the assignment group
g_scratchpad.userInGroup = gs.getUser().isMemberOf(current.assignment_group.toString());
})(current, previous);
onLoad client script: Ensure Isolate Script = False for your client script to allow DOM manipulation
Note: DOM manipulation is not recommended
function onLoad() {
// Check the scratchpad value
if (g_scratchpad.userInGroup.toString() == 'false') {
// Hide the attachments section
var attachmentSection = document.getElementById('header_attachment');
if (attachmentSection) {
attachmentSection.style.display = 'none';
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 05:47 AM
Hi Ankur,
Thanks for response, I have tried your solution but no luck still users who are not member of current assignment group able to access the attachment.
is there anything with the scoped app because sys_attachment is in global scoped note sure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 05:58 AM
should work ideally.
Please share your scripts along with screenshots
Also for your client script did you ensure Isolate Script Field = False
This field is not on form but from list make it False
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader