How to parse a line from email xml and assign to a field

George Taylor
Kilo Contributor

Hi team, 

I've created an Inbound action that creates a task whenever an email is received with certain words are in the body text and got it working. But unable to determine how to parse a particular line that can then be assigned to a variable

For example if I receive the email below and have a task created with this info

Hello, 

<IP_Address> 127.0.0.1 </IP_Address>

<Name> Joe Smith </Name>

<Title> Employee </Title>

 

Is there a way I can grab, say the IP Address as well as Title and assign them each to their own task variable, say u_ip_address and u_user_title? Trying to make it when a task is created I can have these fields auto-filled

Everything I've seen shows how to match but not anything past. 

Thanks in advance!

8 REPLIES 8

Aman Kumar S
Kilo Patron

Hey,

You will need XML parser to achieve this, found one article that does the same:

https://community.servicenow.com/community?id=community_question&sys_id=99428a72dbd3009023f4a345ca9619db

Best Regards
Aman Kumar

Unless I'm reading that page incorrectly it looks like the XML parser sorts out the xml file into a more readable format. While it's impressive I don't think it's doing what I'm looking for, which is to copy the line and make it the value of a variable. 

For example, when an email is received my Inbound rule creates a task, in addition I'd also like for two fields to be filled out based upon what's in the email, in this case IP Address and Title. If it's in your link would you mind pointing it out?

Thanks

Sukraj Raikhraj
Kilo Sage

https://docs.servicenow.com/en-US/bundle/sandiego-application-development/page/script/server-scripting/concept/c_XMLDocumentScriptObject.html

Sukraj Raikhraj
Kilo Sage

if you are using flow designer, the xml parser will make your job so much easier. 

https://docs.servicenow.com/bundle/paris-servicenow-platform/page/administer/flow-designer/reference/xml-parser-step-action-designer.html