Need to exclude additional comments history from worknote

SNOW17
Tera Expert

I want to display only the latest additional comment in the work note and exclude the rest of the comments' history.

I tried the below logic but not working as expected.


var inboundEmailContent = /* get the content of the inbound email */;
var currentAdditionalComments = current.additional_comments || '';

// Exclude email history, signatures, or other parts as needed
var filteredEmailContent = filterEmailContent(inboundEmailContent);

// Append the filtered inbound email content to the existing additional comments
current.additional_comments = currentAdditionalComments + '\n\n' + filteredEmailContent;


current.update();

// Function to filter out unwanted parts from the email content
function filterEmailContent(emailContent) {

// Remove lines starting with "From:", "Sent:", or "To:"
return emailContent.replace(/^From:.*$|^Sent:.*$|^To:.*$/gm, '');
}

1 REPLY 1

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @SNOW17 

 

What is the use case? It is like you want to remove all previous updates which is not recommended.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************