How to hide attachments based on user role

chrish5
Giga Guru

I have a need to hide attachments on Stories from users with the scrum_reader role.   I have created the following onLoad client script on the rm_story table, but when I impersonate a user with the scrum_reader role, I am still seeing the attachment.   What am I missing?

 

function onLoad() {

if(g_user.hasRole('scrum_reader')) {

g_form.disableAttachments();

}

}

1 ACCEPTED SOLUTION

Omkar Mone
Mega Sage

Hi 

please try this in your client script.

gel('header_attachment').style.display='none';

 

Mark correct if it helps.

 

Regards,

Omkar Mone

www.dxsherpa.com

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Chris,

Did you try giving an alert to check whether it is going inside the if condition.

function onLoad() {

if(g_user.hasRole('scrum_reader')) {

alert("Inside has Role");

g_form.disableAttachments();

}

}

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

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

I did  and the alert appeared, so it was going inside the if condition.  

Hi Ankur,

 

I have tried all possible functions in client side on a custom Scoped app table. Ensured the Isolate script in unchecked. Still the 'Manage Attachment' from the top of the form is not hidden. Any suggestions pls?

Omkar Mone
Mega Sage

Hi 

please try this in your client script.

gel('header_attachment').style.display='none';

 

Mark correct if it helps.

 

Regards,

Omkar Mone

www.dxsherpa.com