Mail Script Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 12:25 PM - edited 07-08-2025 01:52 PM
I created a Mail Script to grab the variables to add them to the email notification, it looks like its working perfectly but I notice that Multiple Variable Rows arent being pull into the notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 01:40 PM
This is actually expected: list collectors store multiple values in a GlideList format, and unlike simple string, choice, or reference variables, they need special handling in mail scripts. List collectors store multiple sys_ids, so getDisplayValue() often returns blank or just the sys_id list.
You need to:
Detect if the variable is a list collector.
Query the table it references.
Loop through the selected values and build the display string
The code should look something like this :var variables = ritm.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var v = variables[i];
var question = v.getQuestion();
var label = question.getLabel();
var type = question.getType();
var value = v.getValue();if (type == 19 && value) { // 19 = List Collector
var listValues = [];
var targetTable = question.getReference();
var grList = new GlideRecord(targetTable);
grList.addQuery('sys_id', 'IN', value);
grList.query();
while (grList.next()) {
listValues.push(grList.getDisplayValue());
}
if (listValues.length > 0) {
template.print('<p style="margin: 4px 0;"><strong>' + label + ':</strong> ' + listValues.join(', ') + '</p>');
}
} else {
var displayValue = v.getDisplayValue();
if (label && displayValue && displayValue.toLowerCase() !== 'false') {
template.print('<p style="margin: 4px 0;"><strong>' + label + ':</strong> ' + displayValue + '</p>');
}
}
}
I hope this works for you.
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 01:52 PM
@MihirN Sorry the issue is with MVR's not list collectors