tim2222
Kilo Guru

The Walk-up Experience is great but what if the agent needs to send the customer to another queue?

In our scenario we're using Walk-up Experience to provide virtual queuing for student support. The service is a single-point-of-access but the student may be referred to specialist support in another queue. We need a way for the agent to triage the issue and - if needing referral - put the student in the queue for a specialist.

This implementation requires an AJAX Script Include and Agent Workspace UI Action. While Walk-up is a scoped application we'll do our work in Global scope.

find_real_file.pngfind_real_file.png

Script Include

Create a new Script Include (sys_script_include) called WalkUpAPIAjax.

FieldValue
NameWalkUpAPIAjax
Client callableChecked
DescriptionWrap the WalkUpAPI in a client-callable.
Script
var WalkUpAPIAjax = Class.create();
WalkUpAPIAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	// list currently available locations
	listLocations: function() {
		if (!gs.hasRole('sn_walkup.walkup_technician')) {
			return;
		}
		
		var is_open = this.getParameter('sysparm_open') == 'true';
		
		gs.include('sn_walkup.WalkUpAPI');
		
		var walkup = new sn_walkup.WalkUpAPI();
		
		var queues = [];
		
        var queueGr = new GlideRecord('wu_location_queue');
        queueGr.addActiveQuery();
		queueGr.query();
		while(queueGr.next()) {
			if (is_open && !walkup.isLocationOpen(queueGr.sys_id))
				continue;
			queues.push({
				sys_id: queueGr.getUniqueValue(),
				display_value: queueGr.getDisplayValue(),
				location: queueGr.getValue('location')
			});
		}
		
		return JSON.stringify(queues);
	},
	
	// user, locationQueue, options
	checkIn: function() {
		if (!gs.hasRole('sn_walkup.walkup_technician')) {
			return;
		}
		
		gs.include('sn_walkup.WalkUpAPI');
		
		var sysparm_user = this.getParameter('sysparm_user');
		var sysparm_locationQueue = this.getParameter('sysparm_locationQueue');
		var sysparm_options = this.getParameter('sysparm_options') || '{}';
		
		var user = new GlideRecord('sys_user');
		if (!user.get(sysparm_user)) {
			return 'User not found.';
		}
		
		var locationQueue = new GlideRecord('wu_location_queue');
		if (!locationQueue.get(sysparm_locationQueue)) {
			return 'Location not found.';
		}
		
		var options = JSON.parse(sysparm_options);
		
		try {
			new sn_walkup.WalkUpAPI().checkIn(user, locationQueue, options);
		}
		catch(err) {
			return err;
		}
		
		return '';
	},

    type: 'WalkUpAPIAjax'
});

 UI Action

Create a new UI action (sys_ui_action) called Transfer Location.

FieldValue
NameTransfer Location
TableInteraction [interaction]
Show updateChecked
ClientChecked
Conditioncurrent.state == 'work_in_progress' && current.type == 'walkup'
Workspace Form ButtonChecked
Requires rolesn_walkup.walkup_technician
Workspace Client Script
function onClick(g_form) {
	// get the interaction, so we can filter out the current location
    var intGr = new GlideRecord('interaction');
    intGr.addQuery('sys_id', g_form.getUniqueValue());
    intGr.query(function(intGr) {
        intGr.next();

		// use API to retrieve the list of OPEN locations
        var ga = new GlideAjax('global.WalkUpAPIAjax');

        ga.addParam('sysparm_name', 'listLocations');
        ga.addParam('sysparm_open', 'true');

        ga.getXMLAnswer(function(answer) {
            var choices = JSON.parse(answer)
                .filter(function(queue) {
                    return queue.location != intGr.location;
                })
                .map(function(queue) {
                    return {
                        displayValue: queue.display_value,
                        value: queue.sys_id
                    };
                });

            if (choices.length == 0) {
                return g_modal.confirm('No other queues are open.');
            }

			// present a dialog for the user to choose the location and update the transfer reason
            // https://www.ashleysn.com/post/workspace-ui-actions
            g_modal.showFields({
                title: 'Location to transfer to',
                fields: [{
                        type: 'choice',
                        name: 'location_queue',
                        label: getMessage('Location'),
                        mandatory: true,
                        choices: choices
                    },
                    {
                        type: 'textarea',
                        name: 'reason',
						//label: getMessage('Short description'), // Omit to keep the dialog small
						mandatory: true,
						value: g_form.getValue('short_description')
                    }
                ]
            }).then(function(fieldValues) {
                var queue = fieldValues.updatedFields[0].value;
                var queueName = fieldValues.updatedFields[0].displayValue;
				
                // close current interaction
                g_form.setValue('state', 'closed_complete');
                g_form.save();

				// reason gets copied into the interaction short description
				var options = {
					// reason_id defaults to other
					reason_description: fieldValues.updatedFields[1].value
				};

                // queue into selected queue
                var ga = new GlideAjax('global.WalkUpAPIAjax');
                ga.addParam('sysparm_name', 'checkIn');
                ga.addParam('sysparm_user', g_form.getValue('opened_for'));
                ga.addParam('sysparm_locationQueue', queue);
				ga.addParam('sysparm_options', JSON.stringify(options));
                ga.getXMLAnswer(function(answer) {
                    if (answer != '') {
                        g_form.addInfoMessage(answer);
                    } else {
                        g_form.addInfoMessage('Transferred to ' + queueName);
                    }
                });
                return true;
            }).fail(function() {});
        });
    });
}

 

Version history
Last update:
‎09-24-2021 12:56 AM
Updated by: