Remove [code], [/code] from email notification

Msteiner94
Tera Contributor

Hello,

I am trying to use the below mail script to fetch only the latest comment for our HR Case email notifications. When I test this, it's also pulling in [code] and [/code] tags into the comment body.  How can these be removed?

 

Msteiner94_0-1718649777895.png

 

1 ACCEPTED SOLUTION

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Msteiner94 I have tested the same script in Incident form on my PDI. It is working fine for me. 

Use the below code, it will work for you.

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var latestcommentsare = current.comments.getJournalEntry(1);
    template.print(latestcommentsare);

    // Add your code here

})(current, template, email, email_action, event);

Share your Notification screenshot where you are calling email script? 

SiddharamTakali_0-1718651324597.png

SiddharamTakali_2-1718651433508.png

 

SiddharamTakali_1-1718651339635.png

 

View solution in original post

2 REPLIES 2

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Msteiner94 I have tested the same script in Incident form on my PDI. It is working fine for me. 

Use the below code, it will work for you.

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var latestcommentsare = current.comments.getJournalEntry(1);
    template.print(latestcommentsare);

    // Add your code here

})(current, template, email, email_action, event);

Share your Notification screenshot where you are calling email script? 

SiddharamTakali_0-1718651324597.png

SiddharamTakali_2-1718651433508.png

 

SiddharamTakali_1-1718651339635.png

 

James Chun
Kilo Patron

Hi @Msteiner94,

 

There could be a cleaner way of doing things but you can simply remove those tags via a script, e.g:

template.print(latestcommentsare.replace('[code]', '').replace('[/code]', '') );

 

Cheers