Reading the DISPLAY NAME from an incoming email

Jacob Saaby Ni1
Giga Expert

Hi everyone.

Ran into a perplexing thing today, which I would like your two cents on:

When receiving an email, it's pretty easy to get certain information from that email: Senders email address, subject, body etc.

But - what if I just want to get the display name of the email sender?

I see that it's in the From: in the header. So it says:

From: Jacob Saaby Nielsen <jacob@blabla.com>

How do I get the "Jacob Saaby Nielsen" part from the email headers?

Can't seem to find anything on that.

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

I've searched recently though didn't find anything for this. I was expecting something like "email.user_id".

Ended up with a GlideRecord query on sys_user unfortunately.

See below. Note: this is only part of the whole code!

(function() {
	
	var emailParsed = email.body.caller;
	emailParsed = emailParsed.split(' ');
	
	var grUser = new GlideRecord('sys_user');
	grUser.addQuery('email', emailParsed[0]); // Though, what if this email is not unique?!
	grUser._query();

	if(grUser._next()) {
		var requested_by = grUser.getValue('caller');

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

8 REPLIES 8

ggg
Giga Guru

let me preface this by saying i am new to emails>>> correct anything below that is incorrect >>>

an incoming email creates an incident and populates Caller with the Sender.

you can get display name using caller_id and sys_user as per Mark.

is your requirement to get the display name before the incident is created?

 

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Did this solve your question? Or do we need to follow up on this?

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Did this solve your question? Or do we need to follow up on this?

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Did this solve your question? Or do we need to follow up on this?

Please mark this answer as correct if it solves your problem. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn