- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 09:06 AM - edited 01-09-2025 09:44 AM
Hello All,
I want to print a table in a notification that will be sent every month to submitted by user and that notification includes list of tickets that are raised by the user. I have created a mail script that is used to fetch the details of tickets I am able to get the ticket number and it state in table format but now I want that number to be a type of link and the list will sort in ascending or descending order based on ticket created date.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 08:54 PM
Hi @abhaysingh98 ,
could you please try below script
(function (current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Array to store incident numbers
var arr = [];
// Query active incidents with specified criteria
var gr = new GlideRecord('incident');
gr.addEncodedQuery('active=true^stateIN1,2^activity_leaderDYNAMIC90d1921e5f510100a9ad2572f2b477fe');
gr.orderByDesc('sys_created_on') // add the sorting here
gr.query();
while (gr.next()) {
arr.push(gr.number.toString());
}
// Build rows with clickable URLs
var rows = '';
for (var i = 0; i < arr.length; i++) {
var sr = new GlideRecord('incident');
sr.addQuery('number', arr[i]);
sr.query();
while (sr.next()) {
// Construct the clickable URL
var url = gs.getProperty('glide.servlet.uri') + sr.getTableName() + ".do?sys_id=" + sr.sys_id;
// Add rows to the table
rows += '<tr>';
rows += '<td><a href="' + url + '">' + sr.number + '</a></td>'; // Clickable incident number
rows += '<td>' + sr.getDisplayValue('state') + '</td>';
rows += '</tr>';
}
}
// Build the final table with headers
var data = '';
data = '<table style="border-collapse: collapse;" border="1" cellpadding="5"><thead>';
data += '<tr><th>Incident Number</th><th>State</th></tr></thead><tbody>';
data += rows;
data += '</tbody></table>';
// Print the table in the email
template.print(data);
})(current, template, email, email_action, event);
If my response helped please mark it correct
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2025 08:33 PM
Hi @abhaysingh98 ,
Run daily and also pass opened_By parameter via gs.eventQueue and check send to event param1 true in notification
If my response helped please mark it correct
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 11:52 PM
Hi @Bhavya11 ,
do we need to do glide record of the table before using gs.eventQueue() in scheduled job script.