how to include mailto into a notification script

max_danielewicz
Giga Expert

Hi All,

i hope u r all ok.

Here is the situation

some times where approval via email is required, i use an email template and i call it in the message HTML area of the notification as follows: ${mailto:mailto.approved}. When the approver clicks on the link a new email is created which includes the REF number. Finally, an inbound action reads the received email and identifies the ticket by the ref code.

Problem

i would like to call the mailto.approved template from an email script and i have no idea how to.

would you know how to do this?

Optionally, in the email script i use the following code:

template.print('<a href="mailto:' + inst + '@service-now.com?SUBJECT=' + 'List of Close Contacts Informed' + '&amp;body=sys:'+ current.sys_id + '">Click here after contacting ALL close contacts</a>');

unfortunately, when i click on the link the new email does not includes the REF code. However, i added to the body of the email the sys_id of the record but the inbound action won't work.

var sysid = UserSsysid(email.body.sys);
var gr = new GlideRecord('u_covid_report');
gr.addQuery('sys_id', sysid);
gr.query();
if(gr.next()) {
gr.u_list_informed = true;
gr.comments = "reply from: " + email.from + "\n\n" + "updated via email by " + gr.u_manager;
gr.update();
}

would you know why this code wont work neither?

 

regards,

max

 

1 ACCEPTED SOLUTION

max_danielewicz
Giga Expert

Hi All,

thanks for your responses. Unfortunately, they did not work for me.

In order to solve the issue, i had to change the strategy a bit as per the following.

In the email script

I searched in the sys_watermark for the highest ref number for the specific ticket number and added it to the href. Also, made the subject to be a RE: (reply)

template.print('<a href="mailto:' + inst + '@service-now.com?SUBJECT=' + 'RE: List of Close Contacts Informed' + '&amp;body='+ wnum + '">Click here after contacting ALL close contacts</a>');

 

In the inbound action

changed to be a "reply" and use current values as i now have the watermark in the email.

 

Thanks to everyone for your time and help.

 

View solution in original post

6 REPLIES 6

asifnoor
Kilo Patron

Hi

In your inbound action, try this code.

var sysid = email.body.sys.toString(); 
var gr = new GlideRecord('u_covid_report');
gr.addQuery('sys_id', sysid);
gr.query();

gs.log("Row count is "+gr.getRowCount());
if(gr.next()) {
gr.u_list_informed = true;
gr.comments = "reply from: " + email.from + "\n\n" + "updated via email by " + gr.u_manager;
gr.update();
}

Mark the comment as a correct answer and helpful once worked.

max_danielewicz
Giga Expert

Hi All,

thanks for your responses. Unfortunately, they did not work for me.

In order to solve the issue, i had to change the strategy a bit as per the following.

In the email script

I searched in the sys_watermark for the highest ref number for the specific ticket number and added it to the href. Also, made the subject to be a RE: (reply)

template.print('<a href="mailto:' + inst + '@service-now.com?SUBJECT=' + 'RE: List of Close Contacts Informed' + '&amp;body='+ wnum + '">Click here after contacting ALL close contacts</a>');

 

In the inbound action

changed to be a "reply" and use current values as i now have the watermark in the email.

 

Thanks to everyone for your time and help.