Trying to create task from inbound email action.

trmiller0805
Kilo Explorer

I know it's not best practice but I am not the decision maker so.... rather than make our IT personal actually log in to Service Now and create a ticket, management wants them to be able to send an email to a person within IT, CC the servicenow instance and have service now create a task and assign it to the person in the To field.

 

I have a condition that says:   if email.copied = hpincdev@service-now.com

 

 

(I copied another inbound action then got help from some people I know, I am not a scripter........yet)

 

current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;

current.short_description = email.subject;

 

var eto = email.direct.split(",");

for(var i=0; i<eto.length; i++)

{

    var isUser=getUserFromEmail(eto[i]);

    if(isUser){

  current.assigned_to = isUser;

    break;

  }

}

 

function getUserFromEmail(toemail){

    var gr = new GlideRecord("sys_user");

    if(gr.get("email",toemail)){

  }return gr;}

5 REPLIES 5

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Tracy,



gs.createUser() is deprecated and not recommended for use.


You can   use gs.getUserID() instead.



Best Regards



Tony