How to restrict category variable for each catalog item in the notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 10:37 PM
Hi Team
i am bringing all the variables in notification using below mail script
but the thing is i need to restrict category data variable that is hidden on form which is used for other purpose but the value in this category data variable is populating using category variable in the form with the help of on submit client script
in the notification i am getting two variables category and category data so please suggest how to restrict category data variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 11:48 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 11:08 PM
Can you try with below updated code
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print("<b>Summary of Request</b><br>");
var item = new GlideRecord("sc_req_item");
item.addQuery('request', current.sys_id);
item.query();
if (item.next()) {
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.load();
var vs = set.getFlatQuestions();
// Iterate through all variables
for (var i = 0; i < vs.size(); i++) {
var label = vs.get(i).getLabel(); // Get the label
var name = vs.get(i).getName(); // Get the variable name
var value = vs.get(i).getDisplayValue(); // Get the value
// Skip the "Category Data" variable (modify as needed)
if (name == "category_data" || label == "Category Data") {
continue; // Skip this variable
}
// Print only if the variable has a value
if (value) {
// Split value into lines and process each line separately
var lines = value.split("\n"); // Split by newline characters
template.print(label + ": ");
// Print each line with <br>
for (var j = 0; j < lines.length; j++) {
template.print(lines[j] + "<br>");
}
}
}
}
})(current, template, email, email_action, event);
Please mark correct/helpful if this helps you!