The CreatorCon Call for Content is officially open! Get started here.

Inbound Email Action

ankul
Tera Contributor

Hello everyone,

I create one custom date field in incident form. I want to set the email date timing to my incident date field.

I am trying this but this is not working,

current.u_date = email.date;

current.short_description = email.subject;

Thanks

Ankul Agrawal

4 REPLIES 4

Raju Koyagura
Tera Guru

I don't think email.date is available. Inbound Email Actions - ServiceNow Wiki



There is email.headers variable is available and headers contains date. So first get the header value and split it to get the date then parse it to date object before setting it in your date field.



Example:


var emailHeader=email.headers;


var emailDateSplit=emailHeader.split("Date:");


-----------


---------


pratulagarwal
Mega Expert

Hi Ankul,



If you just want the email date to be updated in a field in the incident table then just write.



current.u_date = gs.now();



This will fetch the current date and put it in the field.



This should serve your purpose, rather than extracting the date from the mail, as the mail will get processed on the same date when it is received.



Regards


Pratul Agarwal


Jamsta1912
Tera Guru

Hi Ankul,


I use the same method as Pratul. But depending on your needs, you have to be aware that gs.now() is never exactly the same as the date-time the email was sent / received, especially if there are issues on an mail server somewhere in the chain. It's probably good enough in most circumstances though.


Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi ankul,



You should be able to use the global variable sys_email.



In your case it should be something like:



current.u_date = sys_email.sys_created_on;


current.short_description = email.subject;



"You can use the global variable sys_email with inbound email actions. This lets you access the received sys_email record that triggered the inbound email action. It can be used to reference fields on the email record, such as uid, sys_id, content_type, and so on."



From nr.15 here : Inbound Email Actions - ServiceNow Wiki