5

Take the ticket widget (Zendesk Classic)

Note: This article applies to Zendesk Classic. The functionality described here exists as a macro in the current version of Zendesk. For more information, see Ticket handling shortcuts.

 

This widget will assign a ticket to you with out having to update the ticket.  If the ticket is already assigned to another agent a pop up will give you the option to steal the ticket or cancel the take over. If a group isn't assigned to the ticket it will set the group to the frist group the agent is a member of. Because the assignment of the ticket is done in the back end you won't see any change in on the ticket page, other people will see it in both the views and the ticket. 

Here is the ticket view Just click on the button Take the Ticket

_598__This_is_another_quick_test_ticket._Hey__hey__it_should_include_correct_credentials._.png

 

After you click take the ticket  you will see in the widget that the owner = you

taketheticket.png

 

If someone else has taken the ticket then you will get the pop up where you can steal the ticket or cancel the assignment.

Chromium-3.png

 

Just create a custom widget and drop this code in. You can also download it from github 

<div id='stealtheticket'>

<div id='stealtheticket'>
<input type='button' value='Take the Ticket' onclick='do\_action();'>
<div style='padding: 4px; font-weight: bold; font-size: 18px;'>
<div id='stealtheticket\_status'></div>
<div id='stealtheticket\_error'></div>
</div>
</div>

<script type="javascript">
// This is the main bit of code, the action that occurs when the "Do" button is hit.
// All other methods should be put into their own little sections
var current_callbacks = {};

log_error = function(arg) {
$('stealtheticket_error').innerHTML = arg;
}

log_status = function(arg) {
$('stealtheticket_status').innerHTML = arg;
}

fade_status = function(arg) {
setTimeout( function() {
log_status('');
}, 3000);
}
do_action = function() {

var current_action = 'steal_ticket';

if (current_action) {
var callback = current_callbacks[current_action];
callback();
}
}

Event.observe(window, 'widgets:load', function() {
current_callbacks['not_yet'] = function() {
log_status("Sorry, that function isn't done yet. :(");
fade_status();
}

current_callbacks['steal_ticket'] = attempt_steal;

});

get_current_user_id = function() {
var _current_user_id = currentUser.id;
return _current_user_id;
}

</script>

<script type="javascript">
// this is all the code for the ticket stealing function.
var ticketId = ticket_id;
var can_update_ticket = false;
var assignee_name = 'Unknown';

attempt_steal = function() {
log_status("Checking one last time...");
check_on_ticket(function() {
do_steal();
});
}

var rootTicket = {};
rootTicket.ticket = {};
rootTicket.ticket.assignee_id = currentUser.id;
var childCall = JSON.stringify(rootTicket);

do_steal = function() {
log_status('Starting...');

var do_it = false;
if (can_update_ticket == false) {
do_it = confirm("This ticket is already owned by " + assignee_name + "\n\nClicking OK will assign this ticket to you.");
} else {
do_it = true;
}

if (do_it) {
$j.ajax('/api/v1/tickets/' + ticketId + '.json', {
type:'PUT',
contentType: "application/json",
accepts: "application/json",
data: childCall,
statusCode: {
200: function(){
log_status("Owner = You");
fade_status();
}
}
});
}
}

check_on_ticket = function(cb_on_success) {
log_status("Attempting to find owner.");

new Ajax.Request('/tickets/' + ticket_id + '.json', {
method:'GET',
asynchronous: true,
onSuccess: function(transport) {
var obj = transport.responseText.evalJSON();
ticket_id = obj['nice_id'];
assignee_name = 'None';

agents.each( function(row) {
if (row['id'] == obj['assignee_id']) {
assignee_name = row['name'];
}
});

log_status("Current Owner: " + assignee_name);

if (assignee_name == 'None') {
can_update_ticket = true;
} else {
can_update_ticket = false;
}

if (cb_on_success !== undefined) {
cb_on_success();
}
},
onException: function(transport) {
log_error('exception: ' + transport.responseText);
},
onFailure: function(transport) {
log_error('failure: ' + transport.responseText);
}
});
}

</script>

35 comments

Please sign in to leave a comment.