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.

Inbound action to find phrase in body of email and update field in record

Bianca Simpson
Kilo Contributor

Hi,

I have the requirement to match the keywords 'General Manager' in an inbound email's body (coming as a reply from an approval email  - the sysapproval table) which updates the 'u_approval_waiting' field in a record to 'general_manager' - in the u_hr table.

What would the inbound action script be for this?

Or is there another way to get the comments from the record (published to the sysapproval table, not u_hr - I figured this out by trying to use flow designer) to update the 'u_approval_waiting' field?

Thanks in advance!

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Bianca, Here you go -

if(email.body.toLowerCase().indexOf("general manager") != -1)

{

//update field

}

Thanks Pradeep.

I know that the target table needs to be on Approval and have it processing (currently nothing) now. When I had it on the u_hr table it didn't work.

What would the update field part be to update the field on the u_hr table?

I tried with the following and it didn't work:

    current.u_waiting_approval = general_manager;
    current.update();

I got the response "did not create or update sysapproval_approver using current"

Hi Bianca,

I believe you need to dot-walk to that email "field" (the name in name:value pair). Try: 

current.u_waiting_approval = email.body.general_manager;

https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/administer/notification/referen...