HTML email body into the RITM

Merza Lyn
Mega Guru

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

MerzaLyn_0-1740647377657.png

 



But the email body in the RITM is like this:

MerzaLyn_0-1740647139346.png


How can I make email body to be like this?
 

MerzaLyn_1-1740647161030.png

 

7 REPLIES 7

kaustubh Desai
Tera Guru

Hello @Merza Lyn ,
Based on my understanding, the HTML in the email body won't render correctly when stored as plain text in the work notes. You may need to create a custom HTML field to store the data properly.



If you found my response helpful, please mark it as correct and close the thread to benefit others.
Regards,
Kaustubh

Ankur Bawiskar
Tera Patron
Tera Patron

@Merza Lyn 

no need of business rule, you can set it in your inbound action

If you want to use business rule then update as this so that it keeps html formatting

current.work_notes = '[code]' + current.variables.email_body + '[/code]';

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

HI @Ankur Bawiskar 

I tried that, but it looks like this.

MerzaLyn_1-1740699266534.png

 

I checked the email preview and it is in table format.

MerzaLyn_0-1740699238936.png

 

@Merza Lyn 

ensure email_body variable is of type Rich text so that it supports HTML

let me know what's the variable type

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader