For incoming emails - how do you set the target?

e_wilber
Tera Guru

I am not using a watermark to update an incoming email - I'm actually going through a glide query and updating it that way.

Because of this, the target is empty (even though the email is updating the record). This causes all the attachments on the email to NOT get copied over to the record.

How do I set the current email target to the glide query record?

6 REPLIES 6

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Eric,



Target is a document id field and it needs to be set differently


Sample script : Adjust it as per your need


var gr = new GlideRecord('sys_email');  


gr.get('81404e364fc0a200bbc32d118110c75c'); //queries one record from email log  


gr.instance = 'b3d7a9b64f7b1200bbc32d118110c741'; //sys_id of incident  


gr.table = 'incident'; //table name of incident  


gr.update();


Hi,



Are you saying I'd include that in the inbound action itself to go back to the email record and set that field? Would that occur in time for the attachments to move over to that record? Or would it simply set the field at the attachments would not be moved?


Hello Eric,



As the watermark is not being used, I think you have to manually set the field on email log table.


I wonder - is it possible to, instead of define a new glide record object, just do var current = new GlideRecord('....') and reuse the name the same way? That way current would be the object instead of having to create a new one?