I am trying to build a custom FreshService app that copies the ticket subject to the clipboard when executed. I have the following code, but when i launch the app from inside a ticket, it appears nothing happens. Not sure what I am doing wrong, but would love help if anyone has it.
$(document).ready( function() {
app.initialized()
.then(function(_client) {
var client = _client;
client.events.on('app.activated',
function() {
client.data.get('ticket')
.then(function(data) {
subject = data.ticket.subject;
var temp_holder = document.createElement("input");
document.body.appendChild(temp_holder);
temp_holder.setAttribute("id", "subject");
document.getElementById("subject").value = subject;
temp_holder.select();
document.execCommand("copy");
document.body.removeChild(temp_holder);
client.interface.trigger("showNotify", {
type: "success",
message: "Subject Copied to Clipboard"
});
});
});
});
});
Thank you
Dave