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.

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,

the script should work; please try adding logs and check where it is breaking

Regards
Ankur

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

Namrata Khabale
Giga Guru

Hey kalava,

Refer the link, it will help you:

https://www.servicenowguru.com/system-definition/email-notifications-system-definition/email-links-u...

 

 Mark it Correct or Helpful, if it works based on impact....!!!!

 

Best Regards,

Namrata.

palanikumar
Giga Sage
Giga Sage

You can try the below code:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
	var link = new GlideSubstituteURL().generateURL(current, '');
	var anchor = "<a href='" + link +"'>" + current.number + "</a>";
})(current, template, email, email_action, event);
Thank you,
Palani

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);

kalava
Giga Contributor

Hi Asif,

I have tried the above script and it's working perfectly.

Thanks for the solution.

 

 

Thanks,

Ramesh Kalava