Notification Email Script - how to add pre-populated email body message when a link containing 'mailto' script is included in the notification email?

MU
Kilo Contributor

Hi All,

I'm seeking assistance on how to best pre-populate the email message window when a user clicks on a notification that they get when a case moves to 'Awaiting Acceptance'. To give more context, if the user is not satisfied with the case resolution, they can click the hyperlink 'here' embedded in the notification email to trigger an inbound action that will move the case from Awaiting Acceptance to Work in Progress.

Upon clicking the hyperlink, I'm able to prepopulate the subject of the email pop-up that the user will get, however, I also want to prepopulate the email body as well with some instructions. Please see the screenshots below to have a better understanding.

I'm not sure if i'm using the 'mailto' script correctly for my use-case.

Thanks,

MU

 

find_real_file.png

 

Below is how the notification for the state Awaiting Acceptance is configured:

find_real_file.png

Actual Email Pop-up window that opens up with clicked on the hyperlink: here

find_real_file.png

The expected email message that should open with the pre-populated message:

 

find_real_file.png

Email Template used in the notification

find_real_file.png

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

You can create a mail script to generate the 'click here' button. You can of course change the text. Then wherever you want to include that button use "${mail_script:reply_button}":

 

The mail script:

find_real_file.png

You can update the subjectTxt and bodyTxt to your liking.

Replace YOURINSTANCEEMAIL@service-now.com with your reply url

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
	var subjectTxt = encodeURI('Re:' + current.number + ' - Please Reopen');
	var bodyTxt = encodeURI('You are requesting to reopen your ticket. Can you please.....');

	template.print('<a title="click here" href="mailto:YOURINSTANCEEMAIL@service-now.com?SUBJECT=' + subjectTxt + '&amp;body='+ bodyTxt + '">Click here</a>');

})(current, template, email, email_action, event);

 

 

The email:

find_real_file.png

 

 

 

The result:

find_real_file.png

 

And in Outlook:

find_real_file.png

 

I created an article for it:

https://community.servicenow.com/community?id=community_article&sys_id=a5650a951b03d0543222ea89bd4bc...

 

Hope this helps! If so, Please mark Correct and Helpful.

View solution in original post

2 REPLIES 2

Willem
Giga Sage
Giga Sage

You can create a mail script to generate the 'click here' button. You can of course change the text. Then wherever you want to include that button use "${mail_script:reply_button}":

 

The mail script:

find_real_file.png

You can update the subjectTxt and bodyTxt to your liking.

Replace YOURINSTANCEEMAIL@service-now.com with your reply url

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
	var subjectTxt = encodeURI('Re:' + current.number + ' - Please Reopen');
	var bodyTxt = encodeURI('You are requesting to reopen your ticket. Can you please.....');

	template.print('<a title="click here" href="mailto:YOURINSTANCEEMAIL@service-now.com?SUBJECT=' + subjectTxt + '&amp;body='+ bodyTxt + '">Click here</a>');

})(current, template, email, email_action, event);

 

 

The email:

find_real_file.png

 

 

 

The result:

find_real_file.png

 

And in Outlook:

find_real_file.png

 

I created an article for it:

https://community.servicenow.com/community?id=community_article&sys_id=a5650a951b03d0543222ea89bd4bc...

 

Hope this helps! If so, Please mark Correct and Helpful.

MU
Kilo Contributor

This is super helpful, thank you very much!