hide/show manage attachement in incident based on user role

pushparaj
Mega Contributor

HI all,

when you open incident form on the top right header label there is manage attachments button(paper clip icon).
i want it to be visible only user with some particular role (like only admin can see that icon) for all others its hidden.

Pls tell me what are the ways to achieve it.

1 ACCEPTED SOLUTION

k, then undo everything done so far.



Just write an onload client script to read the user role and if the user doesn't have the appropriate roles then just


g_form.disableAttachments();


-Anurag

View solution in original post

19 REPLIES 19

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Jayanthi,



This is controlled from write ACL. If particular user is not having write acl i.e. not allowed to write then he/she won't see the icon.


If you want it to be hidden for role "abc" then create a write acl for the table and don't allow the user to write. The icon will automatically be hidden.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

so what table i need to apply ACL on (incident or sys_attachment). And what are the conditions for that.



if i put ACL on sys_attachement table then the user cant add attachements for problem and change as well.(am i right ? )
if i put ACL on incident table ACL i am able to select field of incident, or incident as a whole and i didnt understand what condition i can put to stop attachemnt.



pls explain in detail. I am a bit too weak in ACL


Hi Jayanthi,



Create a write table level ACL on incident table and click the advanced check box. In the script section add this line of code



answer = !gs.hasRole("abc");



what this will do is if the user has "abc" role script will return false and user won't see attachments.


If user has any other role other than "abc" then it will show the attachment icon. But this will allow user to edit form fields unless any specific field level acl is present for the form fields which disallows this user.



Regards


Ankur


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

hi Ankur.
i tried putting a write ACL on incident with none in fields and in advance script i wrote that piece of code u sent.
but when i tried giving a user that role and impersonated him i was able to view attachments, even rename n download them.