Email inbound actions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2023 09:41 AM
I have a requirement like, when a email has been sent, the response from the user has to be captured in Requested item worknotes.
How to configure email inbound for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2023 09:51 PM
Hi @User_267,
When email send to ServiceNow depends on subject ritm worknotes will update it will take new ritm number for new email not static ritm for all.
(function executeRule(current, previous) {
var ritmTable = 'sc_req_item';
var worknotesField = 'work_notes';
var emailSubject = current.subject.toString();
var ritmNumberMatch = emailSubject.match(/RITM(\d+)/);
if (ritmNumberMatch) {
var ritmNumber = ritmNumberMatch[1];
var ritmGR = new GlideRecord(ritmTable);
if (ritmGR.get('number', ritmNumber)) {
ritmGR.work_notes = current.body_text;
ritmGR.update();
}
}
})(current, previous);
Please mark this as solution proposed and helpful if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 12:51 AM
Hi @User_267
There's an existing OOTB Inbound Email Action which is quite similar to your case.
Name: Update Request Item
URL: https://<instance_name>/sysevent_in_email_action.do?sys_id=1e33e31f0a0a3c74015b770ccb3467c4
So to capture the response in Work notes, just update the script from comments to work_notes
Sample below.
if (current.getTableName() == "sc_req_item" && current.canWrite()) {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
}
Let me know if it works for you.
Cheers,
Tai Vu