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

Hi Ankur,

I am close to achive this and i can able to redirect corresponding record.But the strange thing in body it's displaying like below

click here to visit current.number

Instead of that i want display only number with hyperlink similar to current.number like below

LAP432567

Can you please help how to achive this

 

Thanks,

Ramesh Kalava

Hi,

please update as below

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

    // Add your code here

    template.print('<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

Still i am getting current.number.

I want display the ticket number ankur not current.number for example

 

if we take incident INC123456 - so if i click this it will take to this record.So my notification body should display 

INC123456 

In our scenario all the scenarios working in body instead of ticket number it's displaying current.number

Hi,

The script should give number using proper field; which is the field on your table which holds the number; also the notification is on which table

This should work fine; just check once

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

    // Add your code here

    var url = '<a href="' + gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + current.getTableName() + '.do?sys_id=' + current.sys_id + '">' + current.getDisplayValue() + '</a>';  
    template.print(url);  

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

Regards
Ankur

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

Thanks Ankur, I have given correct field name and it's not working tried above code also and it's not displaying number in body.