Can envelope icon by an email address field open system email client instead of user's email client?

Brian Broadhurs
Tera Contributor

We are deriving the Caller's email address from the User record on to the Incident form. An envelope icon appears next to the field. When you click the icon, it open's the current user's email client (e.g. Outlook). We have also enabled the email client on the Incident table, and an envelope icon appears in the form header - if you click on this icon, it opens the Service-now email client.

Is it possible for the icon by the Caller's email address to also open the Service-now email client rather than the current user's client? The issue is that emails sent using the user's email client will have their From address, and any replies will go to them rather than being captured and added to the Incident.

The alternative is to remove the icon from the Caller's email address field - I found a script elsewhere on the forum which will remove the envelope icons, but unfortunately this also removes the icon in the form header. If anyone has an enhanced version of this script, I would be grateful if you could share it with me.

Brian Broadhurst

4 REPLIES 4

CapaJC
ServiceNow Employee
ServiceNow Employee

Unfortunately, the email client icon's link isn't easily grabbable in a client script, since its container anchor doesn't have an ID. I have just checked in a change to put an ID on that anchor tag. This change will be in Winter 2010 Stable 2 next week, and in the Spring 2010 release in May.

Once that was in place, however, I created the following onLoad client script on my incident form, which seemed to do the trick. It's essentially overriding the out-of-box "mailTo()" JavaScript function for just the incident form, finding the onclick attribute of the email client icon, fixing the element passed in the first parameter, and running the onclick. I used the FireBug addon in Firefox to look at what each icon was trying to do onclick:


function onLoad() {
// make client script happy
}

function mailTo(field) {
var e = gel("email_client_open");
if (e) {
var nameField = gel(field);
if (nameField && nameField.value) {
var link = e.getAttribute("onclick");
eval(link.replace("this", "e"));
}
}
}


You can get the "a" tag for the envelope icon by using this. All credit goes to FireBug for helping me find this.



var it = document.getElementById("incident.caller_id.email").nextSibling;


CapaJC
ServiceNow Employee
ServiceNow Employee

"email_client_open" is the necessary bit that won't work until the next stable/release, since the email client anchor element doesn't yet have that as its ID.

But if you or someone else who is interested can find a good way to get that element without using getElementById, the script could probably be made to work with current code.


Thanks, that appears to be exactly what I am looking for. My customer doesn't go live until mid-April, so we can wait for the Stable 2 release.

I assume that I can define the onLoad client script on the Task table and have it inherited by Incident, Problem, Change, etc.?

Brian