Hide email client icon for non itil users

smarti37
Kilo Sage

Hi all ServiceNow guys,

I used the script mentioned on the wiki page to hide the email client icon for non itil user but I detected an undesired impact.


function onLoad()
{
removeEmailIcon();
function removeEmailIcon() {
var yesRole = g_user.hasRoles();
if (!yesRole) {
var refs = document.getElementsByTagName("a");
if (refs) {
for (var i=0; i < refs.length; i++) {
var ref = refs<i>;
var inner = ref.innerHTML;
if (inner.indexOf("email.gifx") > 0){
ref.style.display = 'none';
}
}
}
}
}
}


On my task form, i add a custom glide_list field named "Additional contact" equivalent with the "Watch List" field but used only for non itil user. This field have also the same icon named "email.gifx" as the email client.
I you understand the problem ... the script used to hide the email client icon, hide the email icon of the "additional contact" field too.

Do you have an idea to avoid this problem ?

Regards,
Smarti37.
10 REPLIES 10

Hi Paul,



The scoped application might be what is blocking prototype. Give this a read:



Scoped Applications and Client Scripts: A Primer


There is a system property that you can enable, described in that article, that will allow prototype access in a scoped script. Give that a try.



Thanks


Hi Paul,



Can you please update me on whether or not you had a chance to read that link I sent? That will fix your issue. Issue is the prototype library was not being loaded. That article has the resolution.



Thank you


Ben


Hi Ben,



I was able to try it and it worked as expected. Thanks a lot for your help!


alex_hm_iong
Kilo Explorer

What does "$('email_client_open').hide();" do ?