Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mail Script to service portal with showing ticket number

Bird1
Mega Sage

Hello,

 

I need help.  I am working on mail script to send notification email to end user to route to the ticket on service portal (not Platform UI).  I used below script, it works well to go to the ticket on service portal but the hyperlink name now is 'Link' , anyone has the idea how to get the ticket number on the hyperlink instead of 'Link' (ie. RITM00012334 as hyperlink)

 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,

/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,

/* Optional GlideRecord */ event) {

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'esc?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">Link</a>';

template.print(url);

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

1 ACCEPTED SOLUTION

@Bird1 my bad did not give the correct script try this 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,

/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,

/* Optional GlideRecord */ event) {

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'esc?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">'+current.number+'</a>';

template.print(url);

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

Can you please try the above script ?

View solution in original post

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

@Bird1 Try to use this script and let me know 

use current.number instead of Link text like below  

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,

/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,

/* Optional GlideRecord */ event) {

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'esc?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">current.number</a>';

template.print(url);

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

 

Hope this helps 

Mark the answer correct if this helps you

Thanks

Thanks, but it returns with the wording 'current.number' as hyperlink instead of actual ticket number.

 

Bird1_1-1668440213331.png

 

 

@Bird1 my bad did not give the correct script try this 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,

/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,

/* Optional GlideRecord */ event) {

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'esc?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">'+current.number+'</a>';

template.print(url);

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

Can you please try the above script ?

Thanks a lot., it's workable.