Linking Tasks and Contacts in Agent Workspace

With the change in ServiceNow to the Agent Workspace, the embedded SiX Agent is no longer able to link Tasks and Contacts by default.  This is because Agent Workspace no longer stores the navigation history where the embedded SiX Agent is able to access it.  Therefore a workaround is necessary to get this functionality to work.

1

Create Script Include

First step is to create a new Script Include in ServiceNow.  This is going to be responsible for inserting a history record into ServiceNow's history table.  Be sure to check the Client callable checkbox.

var SixHistoryAjaxIntegration = Class.create();
SixHistoryAjaxIntegration.prototype = Object.extendsObject(global.AbstractAjaxProcessor,{
insertNavigationHistory:function(){
    var tableName=this.getParameter('tableName');
    var sysId=this.getParameter('sysId');
    var description=this.getParameter('description');

    var logRecord = new GlideRecord('sys_ui_navigator_history');
    if(logRecord.isValid()){
        logRecord.initialize();
        logRecord.title = tableName;
        logRecord.url = tableName + ".do?sys_id=" + sysId;
        logRecord.description = description;
        logRecord.user = gs.getUserID();
        logRecord.sys_created_on = gs.nowDateTime();
        var tab = new GlideRecord('sys_db_object');
        tab.addQuery('name', tableName);
        tab.query();
        while (tab.next()){
            logRecord.title = tab.label;
        }
        var newId = logRecord.insert();
    }
    else{
        gs.log("Error in logging history - Log table sys_ui_navigator_history is not valid");
    }
    return newId;
},
    type: 'SixHistoryAjaxIntegration'
});

 

2

Create Client Scripts

For each object in ServiceNow you want to be able to link ( Case, Incident, Request ), you will need to create a new Client Script that will call the Script Include in the previous section.  The type will be onLoad and the UI Type must be Mobile / Service Portal for it to fire in Agent Workspace.

function onLoad() {
    // Used for Agent Workspace to insert records into sys_ui_navigator_history
    // SiX Embedded Agent uses this table to pull in associated records for a call
    // Agent Workspace does not insert into this table by default
    var ajax = new GlideAjax('SixHistoryAjaxIntegration');
    ajax.addParam('sysparm_name','insertNavigationHistory');
    ajax.addParam('tableName',g_form.getTableName());
    ajax.addParam('sysId',g_form.getUniqueValue());
    ajax.addParam('description','Agent Workspace');

    ajax.getXMLAnswer(function(answer) {}); 
}
TOP