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

Mark Stanger
Giga Sage

Try this instead...



if(!g_user.hasRoles()){
$('email_client_open').hide();
}



mark.stanger


Excellent Mark ! Only 2 javascript lines to give 100% satisfaction 🙂
Great Last Day Of The Week for Me 🙂

Thank you so much.


Hi Mark,



I tried using what you provided and was not able to get it to work. I am on Fuji inside a scoped application so I am not sure if that has anything to do with it. Here is what I tried.



hide mail.PNG


peg612
Giga Contributor

Hi Mark,



I also looked at the Chrome Developer Console and saw the following.



[00:00:00.000] onLoad Modify Comments Label


js_includes_doctype.jsx?v=09-01-2015_1202&lp=Wed_Sep_09_20_45_04_PDT_2015&c=6_248:748 ***************************************************


js_includes_doctype.jsx?v=09-01-2015_1202&lp=Wed_Sep_09_20_45_04_PDT_2015&c=6_248:748 A script has encountered an error in render events


js_includes_doctype.jsx?v=09-01-2015_1202&lp=Wed_Sep_09_20_45_04_PDT_2015&c=6_248:748 TypeError: $ is not a function


js_includes_doctype.jsx?v=09-01-2015_1202&lp=Wed_Sep_09_20_45_04_PDT_2015&c=6_248:748 Script ends. Continuing happily


js_includes_doctype.jsx?v=09-01-2015_1202&lp=Wed_Sep_09_20_45_04_PDT_2015&c=6_248:748 ***************************************************


js_includes_doctype.jsx?v=09-01-2015_1202&lp=Wed_Sep_09_20_45_04_PDT_2015&c=6_248:748 [00:00:00.002] Hide Mail Icon


js_includes_doctype.jsx?v=09-01-2015_1202&lp=Wed_Sep_09_20_45_04_PDT_2015&c=6_248:748 [00:00:00.006] ui_policy loaded