Agent view Add ticket to Kbase soutions Button

  • 29 September 2016
  • 3 replies
  • 46 views






Hello,

I was searching for such custom app but unfortunately i found some 2-3-4 years old topics with no resolution. 

Bellow you can find the code to integrate into Agent ticket view a button in order to send the current ticket to solution Knowledge base.


  


jQuery(document).on('sidebar_loaded', function(event,data) {
jQuery("<br><input class='btn btn-primary' onClick='jQuery.fn.myFunction();' id='helpdesk_ticket_submit_kb' value='Create KBase Article'>").insertAfter("#helpdesk_ticket_submit_dup");
});

//Create article
jQuery.fn.myFunction = function(){
//alert('You have successfully defined the function!');
//Create Kbase
jQuery.ajax(
{
url: "https://yoursite.freshdesk.com/solution/categories/[cataegID]/folders/[folderID]/articles.json",
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
cache: false,
headers: {"Authorization": "Basic " + btoa('[yourAgentAPIKEY]' + ":" + 'X')},
data: JSON.stringify('{ "solution_article": { "title": "{{ticket.subject}}", "status": 2, "art_type": 1, "description": "{{ticket.description}}", "folder_id": 17000119974 },"tags": {"name": ""} }'),
success: function(data, textStatus) {
alert(textStatus);
},
error: function(jqXHR, tranStatus) {
alert(jqXHR.responseText);
}
}
);

}

  


Your choice:
"description" : "{{ticket.description}" can contain also {{ticket.latest_public_comment}} or/and {{ticket.latest_private_comment}}





This topic has been closed for comments

3 replies


Great idea... but please provide some details on installing this. I tried adding it as a custom app and it didn't work.



   [yourAPIKEY] -> should be replaced with your API key from Admin view:







On the next page you should see on the right side menu the API section, copy from there and replace in the code. Don't forget to remove the [..] before paste.









Also, you need to replace:




[categID] -> 



[folderID] -> 







<script type="text/javascript">
jQuery(document).on('sidebar_loaded', function(event,data) {

jQuery("<br><input class='btn btn-primary' onClick='jQuery.fn.myFunction();' id='helpdesk_ticket_submit_kb' value='Create KBase Article'>").insertAfter("#helpdesk_ticket_submit_dup");



//Create article
jQuery.fn.myFunction = function(){
jQuery.ajax(
{
url: "https://[yoursite].freshdesk.com/solution/categories/[categID]/folders/[FolderID]/articles.json",
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
headers: {"Authorization": "Basic " + btoa('[yourAPIKEY]' + ":" + 'X')},
data: '{ "solution_article": { "title": "\n' + {{ticket.suject}} + '\n", "status": 2, "art_type": 1, "description": "\n' + {{ticket.description}} + '\n", "folder_id": [folderID]} }',
success: function(data, textStatus) {
alert(textStatus);
window.location = "https://[yoursite].freshdesk.com/solution/folders/[folderID]";
},
error: function(jqXHR, tranStatus) {
alert(jqXHR.responseText);
}
}
);

}




});
</script>

   


Badge

I can't see to get this working on FreshService