Custom App to add Resolve button to top navigation

  • 29 January 2019
  • 1 reply
  • 251 views

Hi,


I'm fairly new at all this and trying to make a simple custom app to add a "resolve" button to the top navigation - IE when they click the button the "status" value of the ticket is changed to "4" (resolved).

After a lot of digging around I've figured out how to get the status of the ticket, but I'm still a little lost as to how I go about setting it to a different value. Can anyone shed some light? 


This is the code I've got in my app.js so far:

  

$(document).ready( function() {
app.initialized()
.then(function(_client) {
var client = _client;
client.events.on('app.activated',
function() {
client.data.get('ticket')
.then(function(data) {
console.log(data.ticket.status);
})
console.log("clicked");

});
});
});

  



This topic has been closed for comments

1 reply

Okay, I think I've mostly got it sorted. If anyone else comes across this and is looking for something similar, this is what I've got currently (apologies if the formatting is off)


 

$(document).ready( function() { 
app.initialized()
.then(function(_client) {
var client = _client;
client.events.on('app.activated',
function() {
console.log("clicked");
client.iparams.get().then(function(data) {
var auth = "Basic " + btoa(data.username+":"+data.password);
client.data.get('ticket')
.then(function(data) {
ticketId = data.ticket.id;
client.request.put("https://<redacted>.freshdesk.com/api/v2/tickets/"+ticketId, {
headers: {
"Authorization": auth,
"Content-Type": "application/json"
},
body: JSON.stringify({
status: 4,
})
}).then(function(data) {
client.interface.trigger("setValue", {id: "status", value: "4"});
client.interface.trigger("showNotify", {
type: "success",
message: "Ticket Status Updated"
});
});
});
});
});
});

});