Hide existing attachments on Requested Item records based on role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2018 07:15 PM
I have a requirement to disable or hide existing attachments on certain RITM records unless the user has a specific role. I'm trying to check for the role of "can_view_ritm_attachments" on RITMs with a short description of "RITM_To_Have_Attachments_Hidden".
I created this read ACL script on the sys_attachment table:
var answer = '';
var gr = new GlideRecord("sc_req_item");
gr.addQuery('sys_id', current.table_sys_id);
gr.addQuery('short_description', 'RITM_To_Have_Attachments_Hidden');
gr.query();
if (gr.next()) {
if (gs.hasRole('can_view_ritm_attachments')){
answer = true;
}
else {
answer = false;
}
}
else {
answer = true;
}
Any ideas why this isn't working? Or maybe a better way to accomplish the attachment lock down? Checking for the short description probably isn't the best for security but I'm sure how I else to find the RITMs that are being created from a specific catalog item.
Thanks,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2018 08:00 PM
HI Andrew,
Try the below code on your table in client script
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.addErrorMessage('ATTACHMENT GONE');
var Attval = "javascript:saveAttachment('sc_req_item','');";
var arrlnk = document.getElementsByTagName('a');
var arrlen = arrlnk.length;
g_form.addInfoMessage('Therefore the number of attachments are '+arrlen);
for (var intcnt = 0; intcnt < arrlen ; intcnt++)
{
strlib = arrlnk[intcnt].getAttribute && arrlnk[intcnt].getAttribute('href');
if(strlib == Attval && g_user.hasRole('can_view_ritm_attachments') )
{
arrlnk[intcnt].style.display = 'none';
}
}
}
PLEASE mark my ANSWER as CORRECT if it served your purpsoe.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2021 02:00 AM
Hello
what is element name in the above code, what we need to mention there at place if 'a',
apart this is there any alternative to hide the attachments in RITM and SCTASK?