Email Notification - Variables info on the Email is not populating correctly

Vaishnavi35
Tera Guru

Hi,

 

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.

This RITM is different from other Templates. 

I only have requested for, Manager(of requested for), request made by variables are only created on the RITM.

1. In the Notification the values are undefined, left side of the Notification

Vaishnavi35_0-1718885889225.png

2. Right side of the Notification,

Except for Requested for and Manager, all are undefined. 

Vaishnavi35_1-1718885962093.png

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.

 

 

 

(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('<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">');
    template.print('<tbody>');

    // Add the header
    template.print('<tr>');
    template.print('<td colspan="2" style="padding: 9px; color: #fff; background: ' + companyColor + ';">');
    template.print('<h1>' + companyName + ' ' + serviceDeskTitle + ': ' + tableHeaderTitle + '</h1>');
    template.print('</td>');
    template.print('</tr>');

    template.print('<tr>'); // Start ROW
    template.print('<td style="width: 400px; padding: 9px;">');

    // Request details at the top
    template.print('<p><table>');
    template.print('<tr><td><strong>Requested Item:</strong></td><td>' + ritm + '</td></tr>');
    template.print('<tr><td><strong>For User:</strong></td><td>' + current.u_requested_for.getDisplayValue() + '</td></tr>');
    template.print('<tr><td><strong>Requires:</strong></td><td>NOTIFICATION ONLY, No Action Required.</td></tr>');
    template.print('</table></p>');
    template.print('<hr style="height: 1px; color: #ccc;" />');

    // 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, '<br />');
        template.print('<p>' + template_message.replace("##RITM##", ritm).replace("##REQ_FOR##", current.u_requested_for.getDisplayValue()) + '</p>');
    } else {
        template.print('<p>Hello --</p>');
        //template.print('<p>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.</p>');
    }

    // Add Request Details
    template.print('<table border="0" style="padding: 4px; border: 1px #ccc solid; background-color: #F2EDED;" width="100%"><tr><td>');
    template.print('<p><ul>');
    template.print('<li><strong>Requested for:</strong> ' + current.variables.u_requested_for_prj.getDisplayValue() + '</li>');
    template.print('<li><strong>Manager:</strong> ' + current.variables.u_requested_for_prj.manager.getDisplayValue() + '</li>');
    template.print('<li><strong>Request made by:</strong> ' + current.variables.u_request_made_by.getDisplayValue() + '</li>');
    // Add specific details based on request type
    // if (ritm == 'Business Unit Project Creation') {
    //     // Add specific details for SAP Security Access request type
    // template.print('<LI><strong>Demand Number</strong> = ' + current.variables.u_demand_number);
	// template.print('<LI><strong>SAP Number</strong> = ' + current.u_sap_number.getDisplayValue());
    // }
    template.print('</ul></p>');

    // Attachments
    mailTemplate.attachLinks(current.sys_id);

    template.print('</td></tr></table>');

    // Add the right summary column
    template.print('<td style="width: 240px; vertical-align: top; padding-right: 5px; padding-top: 5px">');
    template.print('<strong>Requested Item #:</strong> <a href="' + mailTemplate.getUri() + 'nav_to.do?uri=' + current.getLink() + '">' + current.number + '</a>');
    if (current.assigned_to != '') {
        template.print('<br><strong>Assigned To:</strong> ' + current.assigned_to.getDisplayValue() + '<br />');
        template.print('<strong>Email:</strong> ' + current.assigned_to.email + '<br />');
    }
    template.print('<hr style="height: 1px; color: #ccc;" />');
    template.print('<strong>Opened:</strong> ' + current.opened_at.getDisplayValue() + '<br />');
	template.print('<strong>Requested For: </strong>' + current.u_requested_for.getDisplayValue() + '<br />');
	template.print('<strong>Index: </strong>' + current.u_requested_for.user_name + '<br />');
	template.print('<strong>Title: </strong>' + current.u_requested_for.title + '<br />');
	template.print('<strong>Manager: </strong>' + current.u_requested_for.manager.getDisplayValue() + '<br />');
	template.print('<strong>Location: </strong>' + current.u_requested_for.location.getDisplayValue() + '<br />');
	template.print('<strong>Department: </strong>' + current.u_requested_for.department.getDisplayValue() + '<br />');
	template.print('<strong>Business Phone: </strong>' + current.u_requested_for.phone + '<br />');
	template.print('<strong>Email: </strong>' + current.u_requested_for.email + '<br />');
	template.print('<hr style="height: 1px; color: #ccc;" />');
    // Add more summary details if needed
    template.print('</td>');
    template.print('</tr>');

    template.print('<tr>');
    template.print('<td colspan="2" style="background: #ddd; padding: 9px; margin-top: 18px; text-align: center;">');
    if (!isPilot) {
        template.print('<a href="' + mailTemplate.getUri() + '">Login to Service Desk system</a>');
    }
    template.print('</td>');
    template.print('</tr>');
    template.print('</tbody>');
    template.print('</table>');

} catch (ex) {
    template.print('Error: Template: logicalis.htmlEmail.incident.ess.role Error Msg: ' + ex.message);
}

})(current, template, email, email_action, event);

 

 

 

3. On the RITM form as well its different from the variables. Help on this?

Vaishnavi35_2-1718886158095.png

 

Thanks,

Vaishnavi 

1 ACCEPTED SOLUTION

AshishKM
Kilo Patron
Kilo Patron

Hi @Vaishnavi35 , 

As discussed, please update the script for variable's variable print on email notification and share the output.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

1 REPLY 1

AshishKM
Kilo Patron
Kilo Patron

Hi @Vaishnavi35 , 

As discussed, please update the script for variable's variable print on email notification and share the output.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution