<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Email Script to include Variables, Variable Sets, and their values in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325078#M3811</link>
    <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Hello Chaitanya,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Thank you for the suggestions on the script. What you provided fixed the Approver field within the variables [shown below], but the Requested for still displays the sys_id. Any additional thoughts?&amp;nbsp;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MyriahM_1-1752778265623.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/456679i66F4E3D48777C395/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="MyriahM_1-1752778265623.png" alt="MyriahM_1-1752778265623.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jul 2025 18:49:18 GMT</pubDate>
    <dc:creator>MyriahM</dc:creator>
    <dc:date>2025-07-17T18:49:18Z</dc:date>
    <item>
      <title>Email Script to include Variables, Variable Sets, and their values</title>
      <link>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3324882#M3803</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Hello,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Our current script [shown below], created by our implementation partners, is pulling the sys_id instead of the display name for the reference fields within the variables [Approver, Requested for] in our email script. We are reaching out to see if someone might have a fix for this. Also, on a side note, we are looking to include variable sets as well. Any help and/or guidance would be much appreciated.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Script:&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;(function&amp;nbsp;runMailScript(current, template, email, email_action, event) {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;html =&amp;nbsp;'&amp;lt;h2&amp;gt;Summary of Requested Item&amp;lt;/h2&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;reqItem =&amp;nbsp;new&amp;nbsp;GlideRecord("sc_req_item");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; reqItem.addQuery("sys_id", current.sysapproval);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; reqItem.query();&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;if&amp;nbsp;(reqItem.next()) {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;h3&amp;gt;Request Details:&amp;lt;/h3&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;table border="1" cellpadding="5" style="border-collapse: collapse;"&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Request Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&amp;nbsp;+ reqItem.number +&amp;nbsp;'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Requested for:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&amp;nbsp;+ reqItem.requested_for.getDisplayValue() +&amp;nbsp;'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&amp;nbsp;+ reqItem.cat_item.getDisplayValue() +&amp;nbsp;'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Quantity:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&amp;nbsp;+ reqItem.quantity +&amp;nbsp;'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;/table&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;h3&amp;gt;Variables:&amp;lt;/h3&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;table border="1" cellpadding="1" style="border-collapse: collapse;"&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;variables =&amp;nbsp;new&amp;nbsp;GlideRecord("sc_item_option_mtom");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; variables.addQuery("request_item", reqItem.sys_id);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; variables.orderBy("sc_item_option.item_option_new.order");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; variables.query();&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;while&amp;nbsp;(variables.next()) {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;itemOption = variables.sc_item_option.item_option_new;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;label = itemOption.getDisplayValue();&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;value = variables.sc_item_option.value;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;// Handle reference fields - FIX APPLIED HERE&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;if&amp;nbsp;(itemOption.type ==&amp;nbsp;'reference'&amp;nbsp;&amp;amp;&amp;amp; value) {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;refTable = itemOption.reference;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;if&amp;nbsp;(refTable) {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;var&amp;nbsp;refGR =&amp;nbsp;new&amp;nbsp;GlideRecord(refTable);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;if&amp;nbsp;(refGR.get(value)) {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value = refGR.getDisplayValue();&amp;nbsp;// Always get the display value&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;// Handle checkbox display&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;if&amp;nbsp;(itemOption.type ==&amp;nbsp;'checkbox') {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value = (value ==&amp;nbsp;'true') ?&amp;nbsp;'Yes'&amp;nbsp;:&amp;nbsp;'No';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;if&amp;nbsp;(value &amp;amp;&amp;amp; value.trim() !==&amp;nbsp;'') {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;'&amp;nbsp;+ label +&amp;nbsp;':&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&amp;nbsp;+ value +&amp;nbsp;'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; html +=&amp;nbsp;'&amp;lt;/table&amp;gt;';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp; &amp;nbsp; template.print(html);&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&lt;SPAN&gt;})(current, template, email, email_action, event);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2025 15:50:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3324882#M3803</guid>
      <dc:creator>MyriahM</dc:creator>
      <dc:date>2025-07-17T15:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Email Script to include Variables, Variable Sets, and their values</title>
      <link>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3324896#M3804</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/759842"&gt;@MyriahM&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;try this for dispalyaValue instead of sysid&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function runMailScript(current, template, email, email_action, event) {
    var html = '&amp;lt;h2&amp;gt;Summary of Requested Item&amp;lt;/h2&amp;gt;';

    var reqItem = new GlideRecord("sc_req_item");
    reqItem.addQuery("sys_id", current.sysapproval);
    reqItem.query();

    if (reqItem.next()) {
        html += '&amp;lt;h3&amp;gt;Request Details:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="5" style="border-collapse: collapse;"&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Request Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.number + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Requested for:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.requested_for.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.cat_item.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Quantity:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.quantity + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;/table&amp;gt;';

        html += '&amp;lt;h3&amp;gt;Variables:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="1" style="border-collapse: collapse;"&amp;gt;';

        var variables = new GlideRecord("sc_item_option_mtom");
        variables.addQuery("request_item", reqItem.sys_id);
        variables.orderBy("sc_item_option.item_option_new.order");
        variables.query();

        while (variables.next()) {
            var itemOption = variables.sc_item_option.item_option_new;
            var label = itemOption.getDisplayValue();
            var value = variables.sc_item_option.value;

            // Handle reference fields - FIX APPLIED HERE
            if ((itemOption.type == 'reference' || itemOption.type == '8') &amp;amp;&amp;amp; value) {
                var refTable = itemOption.reference;
                if (refTable) {
                    var refGR = new GlideRecord(refTable);
                    if (refGR.get(value)) {
                        value = refGR.getDisplayValue(); // Always get the display value
                    }
                }
            }

            // Handle checkbox display
            if (itemOption.type == 'checkbox') {
                value = (value == 'true') ? 'Yes' : 'No';
            }

            if (value &amp;amp;&amp;amp; value.trim() !== '') {
                html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;' + label + ':&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + value + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
            }
        }

        html += '&amp;lt;/table&amp;gt;';
    }

    template.print(html);
})(current, template, email, email_action, event);(function runMailScript(current, template, email, email_action, event) {
    var html = '&amp;lt;h2&amp;gt;Summary of Requested Item&amp;lt;/h2&amp;gt;';

    var reqItem = new GlideRecord("sc_req_item");
    reqItem.addQuery("sys_id", current.sysapproval);
    reqItem.query();

    if (reqItem.next()) {
        html += '&amp;lt;h3&amp;gt;Request Details:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="5" style="border-collapse: collapse;"&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Request Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.number + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Requested for:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.requested_for.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.cat_item.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Quantity:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.quantity + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;/table&amp;gt;';

        html += '&amp;lt;h3&amp;gt;Variables:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="1" style="border-collapse: collapse;"&amp;gt;';

        var variables = new GlideRecord("sc_item_option_mtom");
        variables.addQuery("request_item", reqItem.sys_id);
        variables.orderBy("sc_item_option.item_option_new.order");
        variables.query();

        while (variables.next()) {
            var itemOption = variables.sc_item_option.item_option_new;
            var label = itemOption.getDisplayValue();
            var value = variables.sc_item_option.value;

            // Handle reference fields - FIX APPLIED HERE
            if ((itemOption.type == 'reference' || itemOption.type == '8') &amp;amp;&amp;amp; value) {
                var refTable = itemOption.reference;
                if (refTable) {
                    var refGR = new GlideRecord(refTable);
                    if (refGR.get(value)) {
                        value = refGR.getDisplayValue(); // Always get the display value
                    }
                }
            }

            // Handle checkbox display
            if (itemOption.type == 'checkbox') {
                value = (value == 'true') ? 'Yes' : 'No';
            }

            if (value &amp;amp;&amp;amp; value.trim() !== '') {
                html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;' + label + ':&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + value + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
            }
        }

        html += '&amp;lt;/table&amp;gt;';
    }

    template.print(html);
})(current, template, email, email_action, event);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for Variable sets you can refer below&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-articles/multi-row-variable-set-in-notifications-via-notifications-email/ta-p/2316858" target="_blank"&gt;https://www.servicenow.com/community/developer-articles/multi-row-variable-set-in-notifications-via-notifications-email/ta-p/2316858&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please mark my answer as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#008000"&gt;helpful/correct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;if it resolves your query.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Regards,&lt;BR /&gt;Chaitanya&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2025 16:00:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3324896#M3804</guid>
      <dc:creator>Chaitanya ILCR</dc:creator>
      <dc:date>2025-07-17T16:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Email Script to include Variables, Variable Sets, and their values</title>
      <link>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325078#M3811</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Hello Chaitanya,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Thank you for the suggestions on the script. What you provided fixed the Approver field within the variables [shown below], but the Requested for still displays the sys_id. Any additional thoughts?&amp;nbsp;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MyriahM_1-1752778265623.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/456679i66F4E3D48777C395/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="MyriahM_1-1752778265623.png" alt="MyriahM_1-1752778265623.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2025 18:49:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325078#M3811</guid>
      <dc:creator>MyriahM</dc:creator>
      <dc:date>2025-07-17T18:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Email Script to include Variables, Variable Sets, and their values</title>
      <link>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325091#M3812</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/759842"&gt;@MyriahM&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function runMailScript(current, template, email, email_action, event) {
    var html = '&amp;lt;h2&amp;gt;Summary of Requested Item&amp;lt;/h2&amp;gt;';

    var reqItem = new GlideRecord("sc_req_item");
    reqItem.addQuery("sys_id", current.sysapproval);
    reqItem.query();

    if (reqItem.next()) {
        html += '&amp;lt;h3&amp;gt;Request Details:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="5" style="border-collapse: collapse;"&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Request Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.number + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Requested for:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.requested_for.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.cat_item.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Quantity:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.quantity + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;/table&amp;gt;';

        html += '&amp;lt;h3&amp;gt;Variables:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="1" style="border-collapse: collapse;"&amp;gt;';

        var variables = new GlideRecord("sc_item_option_mtom");
        variables.addQuery("request_item", reqItem.sys_id);
        variables.orderBy("sc_item_option.item_option_new.order");
        variables.query();

        while (variables.next()) {
            var itemOption = variables.sc_item_option.item_option_new;
            var label = itemOption.getDisplayValue();
            var value = variables.sc_item_option.value;

            // Handle reference fields - FIX APPLIED HERE
            if ((itemOption.type == 'reference' || itemOption.type == '8') &amp;amp;&amp;amp; value) {
                var refTable = itemOption.reference;
                if (refTable) {
                    var refGR = new GlideRecord(refTable);
                    if (refGR.get(value)) {
                        value = refGR.getDisplayValue(); // Always get the display value
                    }
                }
            }

            // Handle checkbox display
            if (itemOption.type == 'checkbox') {
                value = (value == 'true') ? 'Yes' : 'No';
            }

            if (value &amp;amp;&amp;amp; value.trim() !== '') {
                html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;' + label + ':&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + value + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
            }
        }

        html += '&amp;lt;/table&amp;gt;';
    }

    template.print(html);
})(current, template, email, email_action, event);
(function runMailScript(current, template, email, email_action, event) {
    var html = '&amp;lt;h2&amp;gt;Summary of Requested Item&amp;lt;/h2&amp;gt;';

    var reqItem = new GlideRecord("sc_req_item");
    reqItem.addQuery("sys_id", current.sysapproval);
    reqItem.query();

    if (reqItem.next()) {
        html += '&amp;lt;h3&amp;gt;Request Details:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="5" style="border-collapse: collapse;"&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Request Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.number + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Requested for:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.requested_for.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.cat_item.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Quantity:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + reqItem.quantity + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
        html += '&amp;lt;/table&amp;gt;';

        html += '&amp;lt;h3&amp;gt;Variables:&amp;lt;/h3&amp;gt;';
        html += '&amp;lt;table border="1" cellpadding="1" style="border-collapse: collapse;"&amp;gt;';

        var variables = new GlideRecord("sc_item_option_mtom");
        variables.addQuery("request_item", reqItem.sys_id);
        variables.orderBy("sc_item_option.item_option_new.order");
        variables.query();

        while (variables.next()) {
            var itemOption = variables.sc_item_option.item_option_new;
            var label = itemOption.getDisplayValue();
            var value = variables.sc_item_option.value;
            var itemOptionType = itemOption.type;
            // Handle reference fields - FIX APPLIED HERE
            if ((itemOptionType == '31' || itemOptionType == '8') &amp;amp;&amp;amp; value) {
                var refTable = itemOption.reference;
                if (refTable) {
                    var refGR = new GlideRecord(refTable);
                    if (refGR.get(value)) {
                        value = refGR.getDisplayValue(); // Always get the display value
                    }
                }
            }

            // Handle checkbox display
            if (itemOption.type == 'checkbox') {
                value = (value == 'true') ? 'Yes' : 'No';
            }

            if (value &amp;amp;&amp;amp; value.trim() !== '') {
                html += '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;' + label + ':&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + value + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
            }
        }

        html += '&amp;lt;/table&amp;gt;';
    }

    template.print(html);
})(current, template, email, email_action, event);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please mark my answer as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#008000"&gt;helpful/correct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;if it resolves your query.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Regards,&lt;BR /&gt;Chaitanya&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2025 19:05:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325091#M3812</guid>
      <dc:creator>Chaitanya ILCR</dc:creator>
      <dc:date>2025-07-17T19:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Email Script to include Variables, Variable Sets, and their values</title>
      <link>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325110#M3813</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/24805"&gt;@Chaitanya ILCR&lt;/a&gt;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;The script above worked in bringing in the displayName instead of the sys_id for both the Approver and Requested for. As I am slightly newer to scripting and JavaScript, could you please explain to me what you adjusted and how it fixed the issue?&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2025 19:29:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325110#M3813</guid>
      <dc:creator>MyriahM</dc:creator>
      <dc:date>2025-07-17T19:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Email Script to include Variables, Variable Sets, and their values</title>
      <link>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325120#M3815</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/759842"&gt;@MyriahM&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sure&lt;/P&gt;&lt;P&gt;var itemOptionType = itemOption.type;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Handle reference fields - FIX APPLIED HERE&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ((itemOptionType == '31' || itemOptionType == '8') &amp;amp;&amp;amp; value) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have updated the if condition with backend values of variable types&lt;/P&gt;&lt;P&gt;In the backend for reference it 8 and for requested for its 31&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you go to any variables and check the choices of Type field the backend values are different&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can&amp;nbsp; go to the sys_choce table to find the background values or if you have SNUtis with show technical names feature it shows the backend values of chices&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chaitanya&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jul 2025 19:35:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/email-script-to-include-variables-variable-sets-and-their-values/m-p/3325120#M3815</guid>
      <dc:creator>Chaitanya ILCR</dc:creator>
      <dc:date>2025-07-17T19:35:33Z</dc:date>
    </item>
  </channel>
</rss>

