- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 10:42 PM
Hi ServiceNow Community,
I’m looking for some help or guidance on how to create an email script.
What I want to achieve is to include all the variables that are shown at the SCTASK level in the email — either as a summary or in a detailed format. Basically, I’d like to replicate what the requester sees in the catalog task, so that it’s also visible in the email.
Has anyone done something similar or could point me in the right direction to script this?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 12:49 AM
yes, you can create 1 email script and use in the sc_task notification level
Then use below script to show all variables of that catalog item
It will work for any catalog item
Note: you will have to enhance this for printing MRVS
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('RITM Variables: <br/>');
var ritmRecord = current.request_item.getRefRecord();
var variables = ritmRecord.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/>");
}
}
})(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
05-15-2025 12:49 AM
yes, you can create 1 email script and use in the sc_task notification level
Then use below script to show all variables of that catalog item
It will work for any catalog item
Note: you will have to enhance this for printing MRVS
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('RITM Variables: <br/>');
var ritmRecord = current.request_item.getRefRecord();
var variables = ritmRecord.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/>");
}
}
})(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