How to insert a link to the user's opened tickets in the Service Portal?

Jesus Nava
Tera Guru

Hello experts,

Please I need your help, I created an email script to add it to an email notification, here it is:

*******************************************************************************************

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {

// Add your code here
template.print('<p><font size="2" color="#0f0f0f" face="helvetica">');
template.print(gs.getMessage('<br><i>Follow up your tickets in ServiceNow.</i>'));
template.print('</font></p>');

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

****************************************************************************************

What I need is that if the user clicks on "ServiceNow" it takes the user to his opened tickets in the Service Portal,

how can that be done?

here is the SP Portal Page where I need users to be redirected: 

https://company.service-now.com/sp?id=company_my_requests

Thank you!

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

Update your script to

var link = '<div style="margin-top: 16px;"><a href="/sp?id=company_my_requests">ServiceNow</a>';

template.print(gs.getMessage('<p><font size="2" color="#0f0f0f" face="helvetica"><br><i>Follow up your tickets in '+link+'.</i></font></p>'));


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

reshmapatil
Tera Guru

Hi @Jesus Nava ,

 

var link = '/sp?id=company_my_requests';

template.print('<div style="margin-top: 16px;"><a href="' + link + '"');

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

thank you Reshmapatil, I did this:

*************************************************************************************************

var link = '/sp?id=company_my_requests';
template.print('<div style="margin-top: 16px;"><a href="' + link + '"');
template.print('<p><font size="2" color="#0f0f0f" face="helvetica">');
template.print(gs.getMessage('<br><i>Follow up your tickets in ServiceNow.</i>'));
template.print('</font></p>');

**************************************************************************************************

but it puts the link to the whole sentence, is tehre a way to put it just in the word ServiceNow?

Thank you

Hi @Jesus Nava ,

 

Try this:

var instanceName = gs.getProperty('instance_name');

var link = '<a href="https://' + instanceName + '.service-now.com/nav_to.do?uri=rm_story.do%3Fsys_id=' + current.sys_id + '%26sysparm_stack=rm_story_list.do' + '">ServiceNow</a>';

template.print(link);

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

SanjivMeher
Kilo Patron
Kilo Patron

Update your script to

var link = '<div style="margin-top: 16px;"><a href="/sp?id=company_my_requests">ServiceNow</a>';

template.print(gs.getMessage('<p><font size="2" color="#0f0f0f" face="helvetica"><br><i>Follow up your tickets in '+link+'.</i></font></p>'));


Please mark this response as correct or helpful if it assisted you with your question.