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

how to include Catalog task number in the email notification on RITM table?once click on task number record should be open

Santoshi5
Giga Guru

I have created email notification on RITM table i need 3 links on the same notification , 1 is for RITM number and other 2  for sc_task ,

I am using below for RITM number link .but how can i achieve the same for Catalog Task no. on same notification

${URI_REF}

Thanks and advanced.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

for that you need to use mail script

Create new mail script and add it to notification

I assume your email notification is on RITM table

How to call in Notification: ${mail_script:show_sc_task_link}

Name: show_sc_task_link

Mail Script:

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

    // Add your code here

var taskRec = new GlideRecord('sc_task');

taskRec.addQuery('request_item', current.sys_id);

taskRec.query();

while(taskRec.next()){

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

}


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

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

for that you need to use mail script

Create new mail script and add it to notification

I assume your email notification is on RITM table

How to call in Notification: ${mail_script:show_sc_task_link}

Name: show_sc_task_link

Mail Script:

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

    // Add your code here

var taskRec = new GlideRecord('sc_task');

taskRec.addQuery('request_item', current.sys_id);

taskRec.query();

while(taskRec.next()){

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

}


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

Regards
Ankur

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

Hi Ankur,

Thanks for your quick response,

but here is i am missing something,

i am applying same logic to my custom table (parent and child table) it shows all child record number's as link on notification.

RTIM table as- u_source table

sc_task table as- u_entries table

below is the script , 

 please help me where i am doing wrong,

mail script

 

var taskRec = new GlideRecord('u_entries');

taskRec.addQuery('u_number', current.number);//u_number contains number of source table field available on u_entries table

taskRec.query();

while(taskRec.next()){

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

 

result: getting all entries number as link in the source table notification.

 

 

Hi,

so it means the query is not working fine

try checking it

1) is u_number a string field on u_entries table

2) also your notification is on u_source table then check if it is number field or u_number

var taskRec = new GlideRecord('u_entries');

taskRec.addQuery('u_number', current.number);//u_number contains number of source table field available on u_entries table

taskRec.query();

gs.info('Row Count'+ taskRec.getRowCount());

while(taskRec.next()){

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

Regards
Ankur

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

Hi Ankur, 

What if i want to show multiple tasks? For example ... TASK1, TASK2, TASK 3. Can we do this with array?