Bulk Close UI Action from list view in Workspace

Razvan
Tera Contributor

Hello,

I have the following requirement: - to provide the ability of bulk closing specific records (Interactions) from a list view in the CSM Workspace.

 

I have created the following Action Assignment with this code (the Action Assignment is implemented as a Client Script)

 

"function onClick() {

    var checkedRecords = g_list.getChecked();

    if (!checkedRecords || checkedRecords.length == 0) {
        alert('Please select an Interaction or more from the list before using the Bulk close button');
        return;
    }

    var ga = new GlideAjax("BulkCloseRecordsUtils");

    ga.addParam('sysparm_name', 'closeRecords');
    ga.addParam('sysparm_sys_id_list', checkedRecords);

    ga.getXML(closureConfirmation);

    function closureConfirmation(response) {

        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert('Answer is ' + answer);
        var confirmation = JSON.parse(answer);

        if (confirmation == 'success') {
            alert("All selected Interactions were closed.");
        } else {
            alert('There was an error');
        }
    }
}"
 
the Script Include (client callable) has this code:
 
"var BulkCloseRecordsUtils = Class.create();
BulkCloseRecordsUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    closeRecords: function() {

        var debug = true;
        var checkedRecords = this.getParameter("sysparm_sys_id_list");

        if (debug) {
            gs.info('Received the following list of sys_ids ' + checkedRecords);
        }

        checkedRecords.forEach(function(v) {

            if (debug) {
                gs.info('Closing the following Interaction with this sys_id ' + v);
            }

            var imsGr = new GlideRecord("interaction");

            imsGr.get(v);

            imsGr.state = "closed_abandoned";
            imsGr.work_notes = "Interaction was bulk closed.";

            imsGr.update();

            return "success";

        });
    },

    type: 'BulkCloseRecordsUtils'
});"
 
 I am not seeing in the application logs (both scripts are created in an application scope) and the Interaction records are not set to a Closed state.
Any ideas on what I am missing here ?
4 REPLIES 4

Razvan
Tera Contributor

Is there another way of implementing this bulk close functionality on a list view in the CSM workspace?

Hi @Razvan 

 

OOTB it is not available, buy if you want to build, you need to do a lot customization and i think, SN may bring this in upcoming releases. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Razvan
Tera Contributor

What customization are required ?

1. Need to create the UI Action

2. Logic do close open records.

3. Put validation if record is already closed.

4. Need to define role who can use or not this. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************