- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 01:26 AM
Hi,
I have a requirement to pull the sctask short description and populate that short description in the request email notification. How do I achieve that, please help.
The subject should be as show below
Request REQ000001 - "short description from the sctask record" was approved
Regards
Ca
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 02:00 AM
You will need to set the subject through an email script, since you can't get it directly from the config screen.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var reqNr = current.number.getDisplayValue();
var subject = '';
var shortDesc = '';
var shortDescTask = new GlideRecord('sc_task');
shortDescTask.addQuery('request', current.getUniqueValue());
shortDescTask.query();
if (shortDescTask.next()) {
shortDesc = shortDescTask.short_description;
}
subject = reqNr + " - " + shortDesc + " was approved";
email.setSubject(subject);
})(current, template, email, email_action, event);
This is assuming there is only one task and the notification is triggered from the Request record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 01:41 AM
Hello @Carol2,
To achieve the below requirement, create a notification on the request table. Then, use an email script where you perform a GlideRecord query on the sc_task table to check the current request record. Fetch the 'short description' from the sc_task table and include it in the subject.
// Initialize a GlideRecord for the 'sc_task' table
var taskRef = new GlideRecord('sc_task');
// Check if there is a record in 'sc_task' where the 'request' field matches the current record's unique value
if (taskRef.get('request', current.getUniqueValue())) {
// Ensure the 'short_description' field is populated
if (!gs.nil(taskRef.short_description)) {
// Construct the email subject using the current record's number and the task's short description
var taskDescription = taskRef.getValue('short_description'); // Use getValue() for consistent coding standards
var currentNumber = current.getValue('number'); // Use getValue() for clarity
email.setSubject('Request ' + currentNumber + ' ' + taskDescription + ' was approved');
}
}
Please mark my solution as Helpful and Accepted, if it works for you in any way!
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 02:00 AM
You will need to set the subject through an email script, since you can't get it directly from the config screen.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var reqNr = current.number.getDisplayValue();
var subject = '';
var shortDesc = '';
var shortDescTask = new GlideRecord('sc_task');
shortDescTask.addQuery('request', current.getUniqueValue());
shortDescTask.query();
if (shortDescTask.next()) {
shortDesc = shortDescTask.short_description;
}
subject = reqNr + " - " + shortDesc + " was approved";
email.setSubject(subject);
})(current, template, email, email_action, event);
This is assuming there is only one task and the notification is triggered from the Request record.