The CreatorCon Call for Content is officially open! Get started here.

Mail script to send a link to a list of tickets

Dubz
Mega Sage

Hi All,

 

I have a scheduled job checking my incident table for tickets that have been in progress for longer than 4 days, i'm passing an array of the resulting sys_id's through to a notification as parm2 and then looping through them to populate the notification with a series of links to each incident. 

 

The trouble is, if there are a lot of records, the notification gets a bit long. A better solution would be to send out a link to a list of tickets so that recipients can just click on that and view the subset. 

 

Is it possible to dynamically build a link to a list using something like an encoded query string? If so, how do you do it?!

 

Cheers

Dave

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

yes that is possible.

var ids = 'sys_id1,sys_id2_sys_id3,sys_id4' ;     //comma separated list of sys_ids (String)

var link = '<a href="incident_list.do?sysparm_query=sys_idIN'+ids+'" >Incident List</a>';

template.print(link);

View solution in original post

5 REPLIES 5

rammohanraomadd
Kilo Guru

Hi David,

Yes we can pass the link in the event parm2 and then append the link using the email template. For suppose if you get the results as below in your scheduled job:

inc_numbers = "INC000001,INC000002,INC000003,INC000004";

pass the above value in the event parm 2 and below is the email script:

Email Script:

var num = event.parm2;

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'incident_list.do?sysparm_query=numberIN' + num + '">List of Incidents</a>';

template.print(url);

 

Call the Email script from notification.

 

Regards,

Ram M

Not applicable

Hello David,

 

Build a URL for your incident table with an encoded query like below and send it using notification.

URL: https://<instance name>.service-now.com/incident_list.do?sysparam_query=<paste your encoded query>.

 

Hit Like or Correct on the impact of response.

-Tushar

 

 

 

 

Gurpreet07
Mega Sage

yes that is possible.

var ids = 'sys_id1,sys_id2_sys_id3,sys_id4' ;     //comma separated list of sys_ids (String)

var link = '<a href="incident_list.do?sysparm_query=sys_idIN'+ids+'" >Incident List</a>';

template.print(link);

Perfect, thanks Gurpreet, works perfectly.