HTML email body into the RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 01:06 AM - edited 02-27-2025 01:09 AM
I created an inbound action to create RITM
var createRITM = true; // Condition to create a RITM (assuming no duplicate check logic is required)
var curr_record;
// Check if the subject is valid to create a RITM
if (createRITM) {
// Create the cart and add the item (assuming the item ID is the same as in the sample code)
var cart = new Cart();
var item = cart.addItem('c05b5b904704e2102fa8cfba516d43b3'); // Item ID for ATK Shift Change
// Set the variables based on the email content
cart.setVariable(item, 'email_body', email.body_text); // Set email body content
cart.setVariable(item, 'desc', email.subject); // Set email subject as description
cart.setVariable(item, 'email_sender', email.from); // Set email sender
// Place the order and capture the RITM number
var rc = cart.placeOrder();
var ritm = current.number; // Get current RITM number
ritm = ritm.split('M');
ritm = Number(ritm[1]) + 1; // Increment the RITM number for tracking purposes
} else {
var grr = new GlideRecord("sc_req_item");
grr.addQuery("number", ritm); // RITM number query
grr.query();
if (grr.next()) {
curr_record = grr;
}
}
And created Business rule to populate the email body to the RITM activity log
But the email body in the RITM is like this:
How can I make email body to be like this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 07:13 PM
Hi @Ankur Bawiskar
I update my inbound action, but I am not sure if this is correct since it is not working.
var createRITM = true; // Condition to create a RITM (assuming no duplicate check logic is required)
var curr_record;
// Check if the subject is valid to create a RITM
if (createRITM) {
var cart = new Cart();
var item = cart.addItem('c05b5b904704e2102fa8cfba516d43b3'); // Item ID for ATK Shift Change
// Set the variables based on the email content
cart.setVariable(item, 'email_body', email.body_text); // Set email body content
cart.setVariable(item, 'desc', email.subject); // Set email subject as description
cart.setVariable(item, 'email_sender', email.from); // Set email sender
// Place the order and capture the RITM number
var rc = cart.placeOrder();
var ritm = current.number; // Get current RITM number after placing the order
ritm = ritm.split('M');
ritm = Number(ritm[1]) + 1; // Increment the RITM number for tracking purposes
// Now, retrieve the RITM record and update the comments field
var grRITM = new GlideRecord("sc_req_item");
grRITM.addQuery("number", ritm);
grRITM.query();
if (grRITM.next()) {
// Update the comments field with the specified format
grRITM.comments = "received from: " + email.origemail + "\n\n" + email.subject + "\n\n" + email.body_text;
grRITM.update(); // Save the changes to the RITM record
// Now, create an activity log for the RITM with the email content
grRITM.insertActivity("Email received",
"received from: " + email.origemail + "\n\n" +
email.subject + "\n\n" +
email.body_text);
}
} else {
// Handle case where the request already exists (you can modify this logic for checking duplicates)
var grr = new GlideRecord("sc_req_item");
grr.addQuery("number", ritm); // RITM number query (you can adjust the logic as per your needs)
grr.query();
if (grr.next()) {
curr_record = grr;
}
}
I added this lines
var grRITM = new GlideRecord("sc_req_item");
grRITM.addQuery("number", ritm);
grRITM.query();
if (grRITM.next()) {
// Update the comments field with the specified format
grRITM.comments = "received from: " + email.origemail + "\n\n" + email.subject + "\n\n" + email.body_text;
grRITM.update(); // Save the changes to the RITM record
// Now, create an activity log for the RITM with the email content
grRITM.insertActivity("Email received",
"received from: " + email.origemail + "\n\n" +
email.subject + "\n\n" +
email.body_text);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 07:22 PM
check this link and it has solution
Handling inbound emails with HTML in RITM Description field
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 04:13 PM - edited 02-27-2025 04:13 PM
I need this in the RITM activity stream