Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Help with Inbound Email

Wendy Peterson
Tera Guru

I need to look for an inbound email but I want to extract a contract number from it - Here is the example - I want the short description to be CW2230211 PLUS the Subject Line of the incoming email. I tried doing

var stringFromBody = email.body.cw;

current.short_description = stringFromBody + ", " + email.subject;

 

 

Any ideas on how I can achieve to pull that contract number out of there and have it be first plus whatever the subject line is? The above gives me 'Undefined'

2023-11-07_7-45-59.png

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

Hi @Wendy Peterson ,

 

you can extract first line as below

var contract =email.body.the_following_contract_workspace_requires_review; //this would give the entire firs line

contract = contract.split("MSA_"); //split to get contract number

var cw =contract(1) //this would give only contract number

current.short_description = cw+" "+email.subject; //append contract number with short description

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

1 REPLY 1

Hemanth M1
Giga Sage
Giga Sage

Hi @Wendy Peterson ,

 

you can extract first line as below

var contract =email.body.the_following_contract_workspace_requires_review; //this would give the entire firs line

contract = contract.split("MSA_"); //split to get contract number

var cw =contract(1) //this would give only contract number

current.short_description = cw+" "+email.subject; //append contract number with short description

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025