Clear Assigned to on Assignment Group Change in Agent Workspace

SBohare
Tera Contributor

Hello All, 
We have a Requirement where we want to assign multiple tickets to an Assignment Group in ServiceNow and on assigning the "Assigned To" field should clear.

We have the same functionality in Incident Default view and we have tried replicating the Client Script and Script Include for the Agent Workspace. by changing the view of the Client Script to the "workspace" view.

Does not seem to work.

Client Script

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
    var saveAndClose = true;

    //Call function to clear assigned to

    var ga = new GlideAjax('ClearAssignedTo');
    ga.addParam('sysparm_name', 'clearfield'); // Always try to use asynchronous (getXML) calls rather than synchronous (getXMLWait)
    ga.addParam('sysparm_sys_ids', sysIDs);
    alert(sysIDs);
    ga.getXML(parseResponse);

    function parseResponse(response) {

        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert(answer);

    }

    callback(saveAndClose);
}

 
Script Include

var ClearAssignedTo = Class.create();
ClearAssignedTo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    clearfield: function() {
        var grTask = new GlideRecord("incident");
        var incTasks = this.getParameter('sysparm_sys_ids').split(',');
        for (i = 0; i < incTasks.length; i++) {
            grTask.get(incTasks[i]);
            if (grTask.assigned_to != '') {
                grTask.assigned_to = '';
                grTask.update();
            }
        }

    },
    type: 'ClearAssignedTo'

});

 Sharing the SS of the Configurations
Clear assigned to.pngClearedAssignedto.png

16 REPLIES 16

Harshal Aditya
Mega Sage
Mega Sage

Hi @SBohare ,

 

Hope you are doing well.

 

Could you please refer the thread below -

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0960131#:~:text=For%20Scenari....

 

https://www.servicenow.com/community/now-platform-forum/client-script-is-not-working-in-agent-worksp...

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

Hey @Harshal Aditya ,
This did not help since we have followed through all the steps mentioned in the articel

Sandeep Rajput
Tera Patron
Tera Patron

@SBohare Which workspace are you using? Is it the legacy workspace or the configurable workspace. In case of configurable workspace you would need a different view which is called Workspace UIB.

We are using the Legacy workspace. we have tried using the workspace ui view aswell, that did not work.