logo

NJP

Visitor Management: Email notification for Visitor Registration to Host

Import · Jul 17, 2023 · article

Hello Guys,

Problem Statement:

Recently, I came across the email notification for visitor registration, where when the host registered multiple visitors and the email is triggered for each visitor record.

This means, If a host is registering for 10 visitors, then the Email notification is triggering 10 Emails as the email is working on the visitor registration record (sn_wsd_visitor_visitor_registration)and not on the (sn_wsd_visitor_visit).

The Solution:

I have created Email script which will fetch the list of visitors details.

Relationship:

sn_wsd_visitor_visit --> sn_wsd_visitor_visitor_registration --> sn_wsd_visitor_visitor_policy_confirmation

template.print('<table>');
    var visitDetails = new GlideRecord('sn_wsd_visitor_visitor_registration');
    visitDetails.addQuery('source_visit', current.sys_id);
    visitDetails.query();
    template.print("<tr>");
    template.print("<tr>");
    template.print("<td style='font-size: 12.5px; font-weight:bold; border:1px dashed black;'>");
    template.print('Registered visitor');
    template.print("</td>");
    template.print("<td style='font-size: 12.5px; font-weight:bold; border:1px dashed black;'>");
    template.print('Date of visit');
    template.print("</td>");
    template.print("</tr>");
    while (visitDetails.next()) {
        template.print("<tr>");
        template.print("<td style='font-size: 12.5px; border:1px dashed black;'>");
        template.print('' + visitDetails.first_name + ' ' + visitDetails.last_name);
        template.print("</td>");
        template.print("<td style='font-size: 12.5px; border:1px dashed black;'>");
        template.print('' + visitDetails.expected_arrival);
        template.print("</td>");
        template.print("</tr>");
        template.print("</tr>");
    }
    template.print('</table>');

Hopefully this will help someone who is implementing Visitor management.

View original source

https://www.servicenow.com/community/wsd-articles/visitor-management-email-notification-for-visitor-registration/ta-p/2611216