How to change the updation of a incident journal fileds to by System ?

Thej1
Tera Expert

Hi, 

 

We have a custom widget. Whenever the Incident is escalated from the end user, we are updating the fields, additional comments and worknotes.

But it is coming by the name of Requested for in the backend of incident. Instead we want them to be System updated.

Here is the Server Side script of WIdget:

(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
@Community Alums @Sid_Takali 
2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hello,

Please use the appropriate forum feature to insert/edit code into an organization manner...

AllenAndreas_0-1723414238658.png

Outside of that, on initial scan of all this code...I don't see where in your code you are trying to set it to system? Where are you doing that already? (even if it's not working).


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

 

I have not set it to system. How do we do that ?

 

Thanks