Email script help to open link record

kalava
Giga Contributor

Hello Community,

Can any one help below requirement.

I want to display the number in notification body through email script and if i click that number it should be open form view same record and i dont want to open in service portal.

anyone help me with the script it's highly appreciated.

Thanks,

Ramesh kalava

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi

In your script you can do simply like this

var attachLink = '<a href="/incident.do?sys_id='+current.sys_id+'">' + current.number + '</a>'; //put your table name

template.print(attachLink);

View solution in original post

26 REPLIES 26

It's displaying the all the details which we stored in variables in body.i am not getting the number to click

Hi,

Please try below

var instance_name = gs.getProperty('instance_name');
var table= current.getTableName();
var url = "https://"+instance_name+".service-now.com/nav_to.do?uri="+table+".do?sys_id="+current.sys_id;

var TcktNum = current.number ;

var TcktUrl = "<a href="+url+">"+TcktNum+"</a>";

template.print(TcktUrl);

 

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

the link should be something like this

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

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

/* Optional GlideRecord */ event) {

  template.print('Click here to visit <a href="https://give urs instance url here/nav_to.do?uri=incident.do?sys_id=' + current.sys_id + '"> current.number </a>');

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

https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/administer/notification/concept/...

Regards
Ankur

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

Above URL is  not working and getting syntax error ankur

Hi,

please try this

ensure you give valid table name etc

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here

    template.print('Click here to visit <a href="/nav_to.do?uri=incident.do?sys_id=' + current.sys_id + '"> current.number </a>');

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

Regards
Ankur

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