How to mention users @mentions in the backend of incident additional comments and worknotes ?

Thej1
Tera Expert

Hi, 

We have a custom widget 'Incident Standard Ticket Actions'. When the incident is escalated from end user, it will be assign to the new Assignment group ''ABCD", additional comments and work notes are updated in Backend.

In the work notes, we are mentioning the Previous Assigned to person and Previous Assignment group manager, so that they can be notified through email.

 

But we are able to just mention their name but not as @mention (@thej). So the notification is sent.

Please help me to achieve this.

Here are the html code and server side script

 

HTML Code: 

<div>
<div class="dropdown" id="child-case-tabs" ng-if="data.showActions">
<button type="button" id="actions-button" class="btn btn-primary dropdown-toggle action-btn" data-toggle="dropdown" style="width : 100%" aria-haspopup="true" ng-init="setFocusOnActionButtons()">
${Actions}
<span class="fa fa-caret-down"></span>
</button>
<ul class="dropdown-menu pull-right" id="actionList">
<!-- <li ng-if="data.canResolve">
<a href="javascript&colon;void(0)" ng-click="$event.stopPropagation();resolveIncident()">${Resolve}</a>
</li>-->
<li ng-if="data.canReopen">
<a href="javascript&colon;void(0)" ng-click="$event.stopPropagation();reopenIncident()">${Reopen}</a>
</li>
<li ng-if="data.canClose">
<a href="javascript&colon;void(0)" ng-click="$event.stopPropagation();closeIncident()">${Close}</a>
</li>
<li ng-if="data.canEscalate">
<a href="javascript&colon;void(0)" ng-click="$event.stopPropagation();escalateIncident()">${Escalate}</a>
</li>
</ul>
</div>

</div>

 

Server Side:

(function() {
    var incidentGr = new GlideRecord('incident');
    var incidentSysId = options.sys_id;

    if (!incidentSysId && $sp.getParameter('table') == 'incident')
        incidentSysId = $sp.getParameter('sys_id');

    if (!incidentSysId && $sp.getParameter('table') == 'universal_request') {
        var urGr = new GlideRecord('universal_request');
        urGr.get($sp.getParameter('sys_id'));
        incidentSysId = urGr.primary_task + "";
    }
 
 /* Actions - Start */
if (input && input.action == 'escalateIncident' && incidentGr.get(incidentSysId) && hasPermissions(incidentGr, "write")) {

        var assignedToName = '';
        var assignmentGroupManagerName = '';

        if (incidentGr.assigned_to) {
            var assignedToGr = new GlideRecord('sys_user');
            if (assignedToGr.get(incidentGr.assigned_to)) {
                assignedToName = assignedToGr.name.getDisplayValue();
            }
        }

        // Get the manager of the assignment group
        if (incidentGr.assignment_group) {
            var assignmentGroupGr = new GlideRecord('sys_user_group');
            if (assignmentGroupGr.get(incidentGr.assignment_group)) {
                var managerGr = new GlideRecord('sys_user');
                if (managerGr.get(assignmentGroupGr.manager)) {
                    assignmentGroupManagerName = managerGr.name.getDisplayValue();
                }
            }
        }

        var workNotes;

        // Check if both the assigned-to person and the manager are empty
        if (!assignedToName && !assignmentGroupManagerName) {
            workNotes = 'To whom it may concern,\n\n' +
                'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
                'Best regards,\nJarvis';
        }
        // Check if only the assigned-to person is empty and the manager is present
        else if (!assignedToName && assignmentGroupManagerName) {
            workNotes = 'Dear ' + assignmentGroupManagerName + ',\n\n' +
                'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
                'Best regards,\nJarvis';
        }
        // Check if the assigned-to person is present and the manager is empty
        else if (assignedToName && !assignmentGroupManagerName) {
            workNotes = 'Dear ' + assignedToName + ',\n\n' +
                'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
                'Best regards,\nJarvis';
        }
        // If both assigned-to person and manager are present
        else {
            workNotes = 'Dear ' + assignedToName + ', Dear ' + assignmentGroupManagerName + ',\n\n' +
                'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
                'Best regards,\nJarvis';
        }

        incidentGr.assigned_to = '';
        incidentGr.assignment_group = gs.getProperty('xxld_escalated_incident_assignment_group');
        incidentGr.work_notes = workNotes;
        incidentGr.comments = 'Ticket has been escalated and reassigned to the DISC team.';
        incidentGr.u_escalated_status = true;
        data.isIncidentEscalated = incidentGr.update();
        gs.addInfoMessage(gs.getMessage("Request Escalated"));

    } //code ends


    /* Actions - End */

    /* Load incident data */
    if (incidentGr.get(incidentSysId) && hasPermissions(incidentGr, "read")) {
        var incidentUtils = new global.IncidentUtils();
        //  data.canResolve = incidentUtils.canResolveIncident(incidentGr);
        data.canReopen = incidentUtils.canReopenIncident(incidentGr);
        data.canClose = incidentUtils.canCloseIncident(incidentGr);
        data.canEscalate = incidentUtils.canEscalateIncident(incidentGr);
        //  data.showActions = data.canResolve || data.canReopen || data.canClose;
        data.showActions = data.canReopen || data.canClose || data.canEscalate;
    }

    function hasPermissions(gr, operation) {
        if (operation == "read" && gr.canRead())
            return true;

        if (operation == "write" && gr.canWrite())
            return true;

        return (gr.getValue("caller_id") == gs.getUserID()) || (gr.getValue("opened_by") == gs.getUserID());
    }

    data.i18n = {};

})();
 
Thanks
1 REPLY 1