Inbound action - New email update existing ticket

peterquiroz
Giga Contributor

I'm trying create a new inbound action that will update a ticket from a user. User who is not in registered in the system, it can be anybody. So it's not really a reply to email, it's more of a new email with ticket or request number. Any suggestions?

Name: New Hire equipment Shipping update

Target table: "New Hire Asset..."

Type: New -- ??

Condition: email.subject.startsWith("NHA0")

gs.include('validators');

if (current.getTableName() == "New_hire_Asset") {  

  current.u_email_body = "reply from: " + email.origemail + "\n\n" + email.body_text;

}

emailbody = email.body_text.trim().replace('<br>','');

  current.update();

~Peter

1 ACCEPTED SOLUTION

jose_valle
ServiceNow Employee
ServiceNow Employee

Hi Peter,



In this case, because the email is not classified as a reply "current" will represent a new record in the table for which the inbound action is configure.   In order to update the appropriate record, you will need to add code to your inbound action to find and update the correct record using GlideRecord based on values you check for in the subject or body of the email depending on what you are expecting it to contain.



Hope this helps.


-Jose


View solution in original post

5 REPLIES 5

manikorada
ServiceNow Employee
ServiceNow Employee

Peter,



If its new email sent to Service Now then you need to have some unique identifier in the email which will tell you which record it needs to update.


Thanks Mani for your response. We'll have some sort of communication out to users who will send this e-mail. Can we go by condition - email.subject.startsWith("NHA0") and does a look up? or add keypair   Sample: 'Ticket:NHA00421' ?   or anything starting with 'NHA0' do a look up?


Peter,



Yes, since you have the ticket number you can use a GlideRecord to do the lookup and update record.


jose_valle
ServiceNow Employee
ServiceNow Employee

Hi Peter,



In this case, because the email is not classified as a reply "current" will represent a new record in the table for which the inbound action is configure.   In order to update the appropriate record, you will need to add code to your inbound action to find and update the correct record using GlideRecord based on values you check for in the subject or body of the email depending on what you are expecting it to contain.



Hope this helps.


-Jose