How to get the name of the sender from inbound action

shaik_irfan
Tera Guru

Hi,

When i receive the email to servicenow i want to get the name of the sender.

 

1 ACCEPTED SOLUTION

In such case, you get guest.

var name = gs.getUser().getUserByID(email.from_sys_id).getDisplayName();

if(name="guest") {

  name = email.from;

}

View solution in original post

11 REPLIES 11

Hi,

Why don't you just enable "create new users if user is not registered in servicenow" in the email properties?

We did enabled that its more complex like any email that receives creating a record again we enable trusted domain property with this only mention domain emails are getting processed. so final thought is to create users from the inbound action 

 

 

Okay.

Then you have to use email.from in the name as well. 

slight correction to IF: (name == "guest")

Jaspal Singh
Mega Patron
Mega Patron

Hi Irfan,

 

Comments from Asifnoor should work well. In case you still will to follow primitve/old school method you can use below.

var getnameofuser;

var getmailfrom=email.from;

var getname=new GlideRecord('sys_user');

getname.addQuery('email',getmailfrom);

getname.query();

if(getname.next())

{getnameofuser=getname.name; //gives you name

 }