<?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 Notification - Variables info on the Email is not populating correctly in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/email-notification-variables-info-on-the-email-is-not-populating/m-p/2969016#M522987</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/389146"&gt;@Vaishnavi35&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As discussed, please update the script for variable's variable print on email notification and share the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Thanks,&lt;/P&gt;
&lt;P&gt;AshishKM&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2024 16:20:19 GMT</pubDate>
    <dc:creator>AshishKM</dc:creator>
    <dc:date>2024-06-20T16:20:19Z</dc:date>
    <item>
      <title>Email Notification - Variables info on the Email is not populating correctly</title>
      <link>https://www.servicenow.com/community/itsm-forum/email-notification-variables-info-on-the-email-is-not-populating/m-p/2968727#M522977</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an RITM that is getting created when Idea is Accepted. All the field values on the Idea are populated on the RITM variables form. But I have 3 issues.&lt;/P&gt;&lt;P&gt;This RITM is different from other Templates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only have requested for, Manager(of requested for), request made by variables are only created on the RITM.&lt;/P&gt;&lt;P&gt;1. In the Notification the values are undefined, left side of the Notification&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vaishnavi35_0-1718885889225.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/366331i224311714A07E254/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vaishnavi35_0-1718885889225.png" alt="Vaishnavi35_0-1718885889225.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2. Right side of the Notification,&lt;/P&gt;&lt;P&gt;Except for Requested for and Manager, all are undefined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vaishnavi35_1-1718885962093.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/366332i90AA307F3B1EB5C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vaishnavi35_1-1718885962093.png" alt="Vaishnavi35_1-1718885962093.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Email script of my Notification. Dot walking is not working? Only Requested for, Manager and Request made by values are there on the variables section.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
 try {
    gs.include('MailTemplate');
    var mailTemplate = new MailTemplate();
    var companyName = mailTemplate.getCompanyName();
    var companyColor = 'blue';
    if (email_action.name.indexOf('Incident opened') != -1 ||
        email_action.name.indexOf('Incident commented') != -1 ||
        email_action.name.indexOf('Incident Closed') != -1) {
        companyColor = 'green';
    }
    var serviceDeskTitle = mailTemplate.getServiceDeskTitle();
    var isPilot = mailTemplate.isPilot();

    // Set the email subject
    var ritm = current.cat_item.getDisplayValue();
    email.setSubject(email_action.subject.replace("##RITM##", ritm).replace("##REQ_FOR##", current.request.requested_for.getDisplayValue()));

    // Start building the HTML email template
    var tableHeaderTitle = 'Request Received';
    if (email_action.name.indexOf('Request Item Closed (complete)') != -1)
        tableHeaderTitle = 'Request Completed';
    if (email_action.name.indexOf('Request Item Closed (incomplete)') != -1)
        tableHeaderTitle = 'Request Canceled';
    if (email_action.name.indexOf('Request Item Closed (rejected)') != -1)
        tableHeaderTitle = 'Request Rejected';

    template.print('&amp;lt;table style="width: 700px; margin: 50px auto 50px auto; border: 2px ' + companyColor + ' solid; background: #fff; font-size: 12px; font-family: arial, sans-serif;" cellspacing="0" cellpadding="0" align="center"&amp;gt;');
    template.print('&amp;lt;tbody&amp;gt;');

    // Add the header
    template.print('&amp;lt;tr&amp;gt;');
    template.print('&amp;lt;td colspan="2" style="padding: 9px; color: #fff; background: ' + companyColor + ';"&amp;gt;');
    template.print('&amp;lt;h1&amp;gt;' + companyName + ' ' + serviceDeskTitle + ': ' + tableHeaderTitle + '&amp;lt;/h1&amp;gt;');
    template.print('&amp;lt;/td&amp;gt;');
    template.print('&amp;lt;/tr&amp;gt;');

    template.print('&amp;lt;tr&amp;gt;'); // Start ROW
    template.print('&amp;lt;td style="width: 400px; padding: 9px;"&amp;gt;');

    // Request details at the top
    template.print('&amp;lt;p&amp;gt;&amp;lt;table&amp;gt;');
    template.print('&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Requested Item:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + ritm + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;');
    template.print('&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;For User:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;' + current.u_requested_for.getDisplayValue() + '&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;');
    template.print('&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;Requires:&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;NOTIFICATION ONLY, No Action Required.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;');
    template.print('&amp;lt;/table&amp;gt;&amp;lt;/p&amp;gt;');
    template.print('&amp;lt;hr style="height: 1px; color: #ccc;" /&amp;gt;');

    // Introduction sentence taken from the notification form
    if (email_action.u_template_email_message != '') {
        var template_message = email_action.u_template_email_message.replace(/(?:\r\n|\r|\n)/g, '&amp;lt;br /&amp;gt;');
        template.print('&amp;lt;p&amp;gt;' + template_message.replace("##RITM##", ritm).replace("##REQ_FOR##", current.u_requested_for.getDisplayValue()) + '&amp;lt;/p&amp;gt;');
    } else {
        template.print('&amp;lt;p&amp;gt;Hello --&amp;lt;/p&amp;gt;');
        //template.print('&amp;lt;p&amp;gt;A new request task has been assigned to you or your group for fulfillment. Please take the necessary steps to review and fulfill this request.&amp;lt;/p&amp;gt;');
    }

    // Add Request Details
    template.print('&amp;lt;table border="0" style="padding: 4px; border: 1px #ccc solid; background-color: #F2EDED;" width="100%"&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;');
    template.print('&amp;lt;p&amp;gt;&amp;lt;ul&amp;gt;');
    template.print('&amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;Requested for:&amp;lt;/strong&amp;gt; ' + current.variables.u_requested_for_prj.getDisplayValue() + '&amp;lt;/li&amp;gt;');
    template.print('&amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;Manager:&amp;lt;/strong&amp;gt; ' + current.variables.u_requested_for_prj.manager.getDisplayValue() + '&amp;lt;/li&amp;gt;');
    template.print('&amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;Request made by:&amp;lt;/strong&amp;gt; ' + current.variables.u_request_made_by.getDisplayValue() + '&amp;lt;/li&amp;gt;');
    // Add specific details based on request type
    // if (ritm == 'Business Unit Project Creation') {
    //     // Add specific details for SAP Security Access request type
    // template.print('&amp;lt;LI&amp;gt;&amp;lt;strong&amp;gt;Demand Number&amp;lt;/strong&amp;gt; = ' + current.variables.u_demand_number);
	// template.print('&amp;lt;LI&amp;gt;&amp;lt;strong&amp;gt;SAP Number&amp;lt;/strong&amp;gt; = ' + current.u_sap_number.getDisplayValue());
    // }
    template.print('&amp;lt;/ul&amp;gt;&amp;lt;/p&amp;gt;');

    // Attachments
    mailTemplate.attachLinks(current.sys_id);

    template.print('&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;');

    // Add the right summary column
    template.print('&amp;lt;td style="width: 240px; vertical-align: top; padding-right: 5px; padding-top: 5px"&amp;gt;');
    template.print('&amp;lt;strong&amp;gt;Requested Item #:&amp;lt;/strong&amp;gt; &amp;lt;a href="' + mailTemplate.getUri() + 'nav_to.do?uri=' + current.getLink() + '"&amp;gt;' + current.number + '&amp;lt;/a&amp;gt;');
    if (current.assigned_to != '') {
        template.print('&amp;lt;br&amp;gt;&amp;lt;strong&amp;gt;Assigned To:&amp;lt;/strong&amp;gt; ' + current.assigned_to.getDisplayValue() + '&amp;lt;br /&amp;gt;');
        template.print('&amp;lt;strong&amp;gt;Email:&amp;lt;/strong&amp;gt; ' + current.assigned_to.email + '&amp;lt;br /&amp;gt;');
    }
    template.print('&amp;lt;hr style="height: 1px; color: #ccc;" /&amp;gt;');
    template.print('&amp;lt;strong&amp;gt;Opened:&amp;lt;/strong&amp;gt; ' + current.opened_at.getDisplayValue() + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Requested For: &amp;lt;/strong&amp;gt;' + current.u_requested_for.getDisplayValue() + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Index: &amp;lt;/strong&amp;gt;' + current.u_requested_for.user_name + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Title: &amp;lt;/strong&amp;gt;' + current.u_requested_for.title + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Manager: &amp;lt;/strong&amp;gt;' + current.u_requested_for.manager.getDisplayValue() + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Location: &amp;lt;/strong&amp;gt;' + current.u_requested_for.location.getDisplayValue() + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Department: &amp;lt;/strong&amp;gt;' + current.u_requested_for.department.getDisplayValue() + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Business Phone: &amp;lt;/strong&amp;gt;' + current.u_requested_for.phone + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;strong&amp;gt;Email: &amp;lt;/strong&amp;gt;' + current.u_requested_for.email + '&amp;lt;br /&amp;gt;');
	template.print('&amp;lt;hr style="height: 1px; color: #ccc;" /&amp;gt;');
    // Add more summary details if needed
    template.print('&amp;lt;/td&amp;gt;');
    template.print('&amp;lt;/tr&amp;gt;');

    template.print('&amp;lt;tr&amp;gt;');
    template.print('&amp;lt;td colspan="2" style="background: #ddd; padding: 9px; margin-top: 18px; text-align: center;"&amp;gt;');
    if (!isPilot) {
        template.print('&amp;lt;a href="' + mailTemplate.getUri() + '"&amp;gt;Login to Service Desk system&amp;lt;/a&amp;gt;');
    }
    template.print('&amp;lt;/td&amp;gt;');
    template.print('&amp;lt;/tr&amp;gt;');
    template.print('&amp;lt;/tbody&amp;gt;');
    template.print('&amp;lt;/table&amp;gt;');

} catch (ex) {
    template.print('Error: Template: logicalis.htmlEmail.incident.ess.role Error Msg: ' + ex.message);
}

})(current, template, email, email_action, event);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. On the RITM form as well its different from the variables. Help on this?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vaishnavi35_2-1718886158095.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/366333i92393FC4E50D43F0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vaishnavi35_2-1718886158095.png" alt="Vaishnavi35_2-1718886158095.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vaishnavi&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 14:42:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/email-notification-variables-info-on-the-email-is-not-populating/m-p/2968727#M522977</guid>
      <dc:creator>Vaishnavi35</dc:creator>
      <dc:date>2024-06-20T14:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Email Notification - Variables info on the Email is not populating correctly</title>
      <link>https://www.servicenow.com/community/itsm-forum/email-notification-variables-info-on-the-email-is-not-populating/m-p/2969016#M522987</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/389146"&gt;@Vaishnavi35&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As discussed, please update the script for variable's variable print on email notification and share the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Thanks,&lt;/P&gt;
&lt;P&gt;AshishKM&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 16:20:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/email-notification-variables-info-on-the-email-is-not-populating/m-p/2969016#M522987</guid>
      <dc:creator>AshishKM</dc:creator>
      <dc:date>2024-06-20T16:20:19Z</dc:date>
    </item>
  </channel>
</rss>

