How to get the content of the first email received in the case

Rafaeloneil
Giga Contributor
Hi SN Community, 

I'm trying to create a script where I can get the first email received in the case 
(but specifically the message body)


find_real_file.png

Through the code below I can only get the internal work notes:
var gr = new GlideRecord('sn_customerservice_case');
gr.get('bbbc8f5c0fd883405f89e0ba42050e47');
gs.info(gr.work_notes.getJournalEntry(-1));
I need to get the text of the first email in the cases in order to start training a 

machine learning (classification) model on the platform. Any idea how I can get this data?
1 ACCEPTED SOLUTION

RAHUL YADAV9
Mega Guru

You need to refer sys_email table. All the email sent or received are stored in this table. You can put filters to get your desired result and into this table you have a field called body that holds the body of the email received.

Feel free to mark correct and helpful.

View solution in original post

2 REPLIES 2

Chandu Telu
Tera Guru
Tera Guru

Hi Rafaeloneil,

There is one related email table you get the data first email from table  Check it in related list on Case table

Check the below link

https://community.servicenow.com/community?id=community_question&sys_id=ef1a5a3bdbb90d50e515c223059619fa

 

Thanks

Chandu Telu

RAHUL YADAV9
Mega Guru

You need to refer sys_email table. All the email sent or received are stored in this table. You can put filters to get your desired result and into this table you have a field called body that holds the body of the email received.

Feel free to mark correct and helpful.