Skip to main content





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/ecataegID]/folders/rfolderID]/articles.json",
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
cache: false,
headers: {"Authorization": "Basic " + btoa('ayourAgentAPIKEY]' + ":" + '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}}





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 h..] before paste.









Also, you need to replace:




acategID] -> 



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://pyoursite].freshdesk.com/solution/categories/rcategID]/folders/dFolderID]/articles.json",
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
headers: {"Authorization": "Basic " + btoa('tyourAPIKEY]' + ":" + 'X')},
data: '{ "solution_article": { "title": "\n' + {{ticket.suject}} + '\n", "status": 2, "art_type": 1, "description": "\n' + {{ticket.description}} + '\n", "folder_id": ifolderID]} }',
success: function(data, textStatus) {
alert(textStatus);
window.location = "https://pyoursite].freshdesk.com/solution/folders/dfolderID]";
},
error: function(jqXHR, tranStatus) {
alert(jqXHR.responseText);
}
}
);

}




});
</script>

   




I can't see to get this working on FreshService