Automatic user creation from inbound emails

edgar_evangelis
Tera Contributor

Hi,

 

Is there a way to customize how glide.pop3readerjob.create_caller automatically creates users in Service Now.

 

e.g.

from Edgar Evangelista<edgar.evangelista@xyz.com>

 

Service now should pick up:

Edgar = First Name

Evangelista = Last Name

Username = edgar.evangelista

3 REPLIES 3

xiaix
Tera Guru

::raises hand::     ...     I too would like to know how to customize this.


thenckel
Mega Contributor

You would think there would be some way to customize this by now, granted there are inbound actions available but those still don't quite touch the user records like I would like to see.


nic8
ServiceNow Employee
ServiceNow Employee

Hi Edgar



We have just built an internal tool that does what you are looking for . There is no automated, or easily configurable option for customisation of created users yet, to my knowledge. But this can be done in the following way:



Step 1) Email properties. DISABLE "Automatically create users for incoming emails from trusted domains"


Step 2) Modify the appropriate "Create Task" Inbound Action. And create the users manually with a little script magic.



//See if the users already exists for the inbound mail


var userRecord = new GlideRecord('sys_user');


userRecord.addQuery('email', email.origemail);


userRecord.query();


if(userRecord.next()){


current.caller_id = userRecord.sys_id;


current.opened_by = userRecord.sys_id;


}


else{



// If no users exists, create a new user


var new_user_record = new GlideRecord('sys_user');


new_user_record.initialize();



new_user_record.email = email.origemail;


new_user_record.first_name = email.origemail;


new_user_record.user_name = email.origemail;



var user_created = new_user_record.insert();


if(user_created != ''){


current.caller_id = user_created;


current.opened_by = user_created;


}


}