- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 11:45 PM
Hello All ,
There is a requirement to display Variable Information in Approval Notifications for a Record Producer submitted in a Scoped Application, so for that we are using this email script somehow it is working , But variable details are showing up duplicate.
This is the script we use :
This is the approval notification but there are duplicate variables are showing up, Please guide.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 04:40 AM
Glad to know that my script worked fine.
To hide false values enhance as this
I added this extra condition in the IF
&& tbl_obj.variables[key].getDisplayValue() != 'false'
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
if (current.source_table == "x_tmms7_finance_finance_ticket") {
template.print("Summary of Finance Ticket ");
}
template.print('<table border="1">');
var tbl_obj = new GlideRecord('x_tmms7_finance_finance_ticket');
tbl_obj.get('sys_id', current.sysapproval);
// Use a Set to track processed variables
var processedVariables = new Set();
for (var key in tbl_obj.variables) {
if (tbl_obj.variables[key] && !processedVariables.has(key) && tbl_obj.variables[key].getDisplayValue() != 'false') {
template.print("<tr>");
template.print("<td>" + getQuestionLabel(key) + "</td>\r\n");
template.print("<td>" + tbl_obj.variables[key].getDisplayValue() + "</td>\r\n");
template.print("</tr>");
// Mark this variable as processed
processedVariables.add(key);
}
}
template.print("</table>");
function getQuestionLabel(question) {
var vara = new GlideRecord('item_option_new');
vara.addQuery('name', question);
vara.query();
if (vara.next()) {
return vara.question_text;
}
return question;
}
})(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
04-23-2025 04:58 AM - edited 06-04-2025 07:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 05:06 AM
I believe I have already answered your original question and subsequent question.
Please mark both of my answers as correct as you can now mark multiple responses as correct.
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
04-23-2025 05:10 AM
you can also enhance the script to check if the record is for variable or variable set
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
04-23-2025 04:06 AM
Is it possible that there is more approvals? with that creating the approver, reviewer fields again
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */