We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Show attachment only if user has specific role

Priya Gautum
Kilo Guru

Hi There,

Can someone please suggest how to show the attachment for two tables if the user has a specific Role?

And if the user doesn't have this role they should not be able to see those table attachments. 

Requirement: Two Tables (change & Problem)

Role: u_mgmt_user

Regards,

Priya

3 REPLIES 3

Tudor
Tera Guru

Hello Priya,

You will require an ACL on sys_attachment.

Read operation and condition: table name is problem or change_request

Plus the role.

Please give it a try and provide feedback.

 Tudor

Priya Gautum
Kilo Guru

Hey,

I did it but it's not working.

Not applicable

You can introduce a read ACL on sys_attachment table. 

In the advanced scripting section you can have following script

getAttachmentReadAnswer();


function getAttachmentReadAnswer() {


// if table is change request and user has this role then this acl evaluates to true and attachments will be seen


if ((current.table_name == 'change_request'||current.table_name == 'problem' )&& gs.hasRole('u_mgmt_user'))


return true;


}


return false;


}