remove the unwanted content in inbound emails

Prerana1
Kilo Guru

Hello Guys,

We have created the inbound actions to create the ticket when OTRS tool send an email to Servicenow but along with the mail the extra content is also updating in the ticket( see the print screen) i want to eliminate the extra content and to keep only the main content, i have written a code but no luck.

Can anyone guide me with this Please?

find_real_file.png

find_real_file.png

Thanks and Regards,

Prerana

1 ACCEPTED SOLUTION

Hello Prenana, I tried with another approach and it worked:


var body = email.body_text;


var expectedTxt= body.split("Bitte denken Sie an")[0] ; // add your line here or keep 4 words

gs.log("expectedTxt: "+expectedTxt);

Thank You!
Abhishek Gardade
ServiceNow MVP 2020

Thank you,
Abhishek Gardade

View solution in original post

13 REPLIES 13

Hello Prenana, I tried with another approach and it worked:


var body = email.body_text;


var expectedTxt= body.split("Bitte denken Sie an")[0] ; // add your line here or keep 4 words

gs.log("expectedTxt: "+expectedTxt);

Thank You!
Abhishek Gardade
ServiceNow MVP 2020

Thank you,
Abhishek Gardade

Thank you so much for your help!

 

 

Community Alums
Not applicable

Hi Prerana,

 

Instead of replace you can use slice(). Try this code:

var body1 = body.slice(0,body.indexOf("Bitte denken Sie"));

It will simple remove all the text after the keyword "Bitte denken Sie".

Here is a little example I tried:

find_real_file.png

 

Thank you,

Debopriya

Thank you so much for your reply!

 

Thanks,

Prerana