Start a new topic

App Assistance: Copy Ticket Subject to Clipboard

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

Turned out to be a chrome extension blocking the execution of the app.  Disabled extension and things seemed to work ok.  now the challenge i am facing is that data.ticket.id returns a very long integer, but not the actual ticket number in the helpdesk.  does anyone know the ticket data field that contains the actual ticket number?

Login or Signup to post a comment
JS Bin