Getting date/time value from the email notification and then pass it over to the other field

Ramel
Mega Guru

Hi All,

I just want to ask how to get the date/time the email notification was sent. Then after getting the value I want to pass that value to another field that is within the same form. Example, the email notification was sent when an INC is created, I want to be able to get the date/time the email was sent and I will pass that value to another date/time field that exist in the incident form. It will just be used for reporting purposes.

Thanks in advance.

Ramel

1 ACCEPTED SOLUTION

Hi Ramel,

you would require business rule on email logs[sys_email] table and then pick the time when the type changes to sent and populate the updated time in incident record field.

Condition should be such that it only works for incident table

BR: On sys_email

After Update:

Condition: Target table is incident AND Type is sent

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here

	var inc = current.document_id;
	var gr = new GlideRecord('incident');
	gr.get(inc);
	gr.<field> = current.sys_updated_on; // give here the custom date time field
	gr.update();

})(current, previous);

find_real_file.png

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ramel,

you would require business rule on email logs table and then pick the time and populate in incident record

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks Ankur, can you advise how do I do the query. Thank you.

Hi Ramel,

you would require business rule on email logs[sys_email] table and then pick the time when the type changes to sent and populate the updated time in incident record field.

Condition should be such that it only works for incident table

BR: On sys_email

After Update:

Condition: Target table is incident AND Type is sent

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here

	var inc = current.document_id;
	var gr = new GlideRecord('incident');
	gr.get(inc);
	gr.<field> = current.sys_updated_on; // give here the custom date time field
	gr.update();

})(current, previous);

find_real_file.png

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks a lot Ankur.