- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 01:33 PM
Had a look and this seems to have been an issue many have had.
I'm currently using a mail script which is working for all other task records (sc_task and inc) when they are assigned to an ITIL user to work through, but records that were created via a record producer come up empty.
The actual fields are being utilized such as short_description which is puzzling me since I'd think they would pull like normal.
Any help would be much appreciated.
Script Below:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
for (var key in current.variables)
{
var v = current.variables[key];
if(v && v.getDisplayValue() != 'false')
{
template.print(v.getGlideObject().getQuestion().getLabel() + " " + v.getDisplayValue() + " <br>");
}
}
template.print('<hr/>');
})(current, template, email, email_action, event);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 06:56 AM
Thanks for confirmation.
Now if you want to bring in RITM's variable on sc_task notification then use this in email script and it will work
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var ritmObj = current.request_item.getRefRecord();
var variables = ritmObj.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
if(label != ''){
template.space(4);
template.print(' ' + label + " = " + value + "<br/>");
}
}
template.print('<hr/>');
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2024 07:40 AM
Hi @Ankur Bawiskar - following up on the message about false or empty fields being captured, I've modified the script you provided to filter these and the data is looking good!
Greatly appreciate the assistance on this. I'm going to verify with some edge testing and if working fully I will accept your post as solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 08:01 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader