- 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-14-2025 10:52 PM
Hello,
You can use ${variables."Your Variable Name"} it will work if notification is built on same table. If not, you need to write an email script.
For script you can refer: https://www.servicenow.com/community/itsm-forum/i-want-to-display-all-catalog-variables-on-notificat...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 10:56 PM
Hello,
You can use ${variables.NameOfYourVariable} or you can write a email script as shared in this post.
https://www.servicenow.com/community/itsm-forum/i-want-to-display-all-catalog-variables-on-notificat...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 11:03 PM
you would know which all variables are made available on sc_task level
simply use the below script and show those variables in email script, notification on sc_task level
Use the variable labels you want to show in the array
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
template.print('RITM Variables: <br/>');
var ritmRecord = current.request_item.getRefRecord();
var variablesToBeShown = ['variableLabel1', 'variableLabel2', 'variableLabel3'];
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 != '' && variablesToBeShown.indexOf(label) > -1) {
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:01 AM
Hi Ankur,
Thanks for the script — let me expand a bit more on my use case...
Right now I have around 20 catalog items, and the idea is to show the details of each catalog item in the task-level email notification. Is that possible or feasible in some way? Something like showing a request details summary or similar, depending on the RITM the task belongs to?
Appreciate your input — thanks again!
Best regards,
Juan