Display variable and Multiple row variable sets data into approver email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 05:02 AM
Hello,
I am trying to display variable and multiple row variable set data in an approval email notification.
in a line by line manager. as shown in the picture.
Process: A case gets created with variables and multiple row variable sets, then approver gets triggered and then this email gets triggered to approver.
i am currently using this script in email script to print the variable data but now i need for both variables and multiple row variable sets.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 09:57 PM
for normal variables you already have the above logic; just add the script shared in the article
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:56 AM - edited 07-24-2023 10:56 AM
Hello @Ankur Bawiskar
I tried the following script to print the variable data, it is working fine.
But how to dynamically print the varible set data along with these? please help with the script
My script:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
template.print("<table border = 0.5 style=width:100% bgcolor='white'>");
var item = new GlideRecord('finance_table');
item.get('sys_id', current.sysapproval);
for (var key in item.variables) {
if (key != 'gsf_routing_type_service_offering' && key != 'csm_requested_for' && key != 'routing_type') {
template.print("<tr>");
if (item.variables[key]) {
template.print("<td><strong>" + getQuestionLabel(key) + "</strong></td>\r\n");
template.print("<td>" + item.variables[key].getDisplayValue() + "</td>\r\n");
template.print("</tr>");
}
}
}
template.print("</table>");
function getQuestionLabel(question) {
// gs.info('Give me question value ' + question);
var vara = new GlideRecord('item_option_new');
//vara.addEncodedQuery('name!=internal_contact^ORname!= gsf_routing_type_service_offering^name='+question);
vara.addQuery('name', question);
vara.query();
if (vara.next()) {
gs.info('variable ' + vara.question_text + " " + question);
var question_label = vara.question_text;
return question_label;
}
}
})(current, template, email, email_action, event);