Hiding the Attachments user now member of current assignment group.

yadi
Tera Contributor

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

7 REPLIES 7

GopikaP
Mega Sage

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.

Ankur Bawiskar
Tera Patron
Tera Patron

@yadi 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.

@yadi 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader