Inbound action - getting the watermark

e_wilber
Tera Guru

I have an interesting situation.

I need to know the watermark of an incoming email.

The below code shows that it does actually find my Ref:MSG### in the email.

if (email.body_text.indexOf(/Ref:MSG\d+/gi)) {

  gs.log('found watermark');

}

However, my watermark is empty and the entire line refuses to print. I have a feeling it's because the email.body_text is encrypted and is preventing me from getting the value?

var foundMark = email.body_text.match(/Ref:MSG\d+/gi).toString();

gs.log("Watermark is: " + foundMark); // Nothing prints, not even the "Watermark Is";

I tried the obvious gs.log(email.watermark) but that didn't work. My end goal is having the watermark stored in a string so I can do some additional processing on it.

4 REPLIES 4

Chuck Tomasi
Tera Patron

How about reverse engineering it? If you know the record you are using (eg. Incident INC0010020) or you have the current.sys_id, you could get the watermark from the sys_watermark table based on the source_id of the record you got.



Example:



var wm = new GlideRecord('sys_watermark');


if (wm.get('source_id', current.sys_id))


        gs.log('your watermark is ' + wm.number);


That only works though if 1 type of notification has been triggered off that record though. It'd be extremely helpful to know what type of notification that the user is replying to.


M_87
Tera Contributor

Having the same problem, did you eventually managed to get this working?

I know when it is a reply mail the email.body_text is stripping the previous reply content, so also the Ref:MSG on the bottom, that is why it is not in the email.body_text.

Nihal Sarawgi1
Tera Contributor

@M_87 @e_wilber 

 

Did you guys got any solution for this ?