Vor Kurzem aufgerufene Suchen
Keine vor kurzem aufgerufene Suchen
Export view to CSV file without 10 min limit
Gepostet 10. Apr. 2015
Introduction
Perhaps you are faced with the problem of the CSV file request frequency limit.
To work around this, we use small javascript (bookmarklet) that receives the data via Zendesk API and saves it to a CSV file.
You can get the script HERE to set it up for yourself. It`s open source and FREE. Enjoy!
How it works
This video shows how it works.
Here's the source code
Following is the script code. Feel free to modify it for your own needs!
javascript:var win=window.open("","","width=600,height=500,scrollbars=yes");var vn=+window.location.href.replace(/(.*filters\/)/,""); var w=win.document; w.write("<p style='font-family: Arial; color:black; margin:3; font-size: 12; align-text:right;'>Export view to CSV file <a href='http://app1.roundrobin-assignment.com/?utm_source=prs' target=' _blank'>Created by Round Robin App team</a> (<a href='https://twitter.com/RoundRobinApp' target=' _blank'>@RoundRobinApp</a>)</p><div style='background-color:#4C4F53; margin-bottom:15'><input type='text' id='fn' value='view"+vn+".csv' style='margin:4'><button type='button' onclick='mycl()'>Save</button></div>"); w.write("<script>function mycl(){var saveData = (function () { var a = document.createElement('a'); document.body.appendChild(a); a.style = 'display: none'; return function (data, fileName) { try{ var blob = new Blob([data], {type: 'octet/stream'}); var url = window.URL.createObjectURL(blob); a.href = url; a.download = fileName; a.click(); setTimeout(function(){window.URL.revokeObjectURL(url);}, 2000); } catch(e) {alert('Your browser does not support saving files created on the client side. Please use Copy and Paste.')} }; }());var data=document.getElementById('data').innerHTML;data=data.replace(/(<br.*>)/g,'');var fileName = document.getElementById('fn').value;saveData(data, fileName);}</script>");var url="/api/v2/views/"+vn+"/execute.json";var l=1;f(url);function ai(a, s, p){for(var i = 0, len = a.length; i < len; i++){if (a[i][p] === s) return i;} return -1;}; function gv(o, r, a){var v=o.rows[r][a]; if (typeof v == "undefined") {v=o.rows[r][a+"_id"];}; if (v !== null) {if(a=="assignee" || a=="requester"){return o.users[ai(o.users, v, "id")].name}; if (a=="group") {return o.groups[ai(o.groups, v, "id")].name};if (a=="organization"){return o.organizations[ai(o.organizations, v, "id")].name};if (a=="via"){return v.channel}; return v;} else {return ""};};function f(u){var xh=new XMLHttpRequest();xh.onreadystatechange=function() {var obj; if(xh.readyState==4&&xh.status==200){obj=JSON.parse(xh.responseText); w.write("<div id='data'style='font-family:Arial;font-size:14;'>"); var q=String.fromCharCode(34); var q1 =String.fromCharCode(39); var s="id,Description"; if (l == 1) {for (var j = 0; j < obj.columns.length; j++) { s += ","+q+obj.columns[j].title+q; }; l=0; w.write(s+String.fromCharCode(13,10)+"<br id=0>"); }; for (var i = 0; i < obj.rows.length; i++) {var s=obj.rows[i].ticket.id+","+q+obj.rows[i].ticket.description.replace(/[\r\n]/g," ").replace(/"/g, q1).replace(/\s+/g, " ")+q; for (var j = 0; j < obj.columns.length; j++) {s += ","+q+gv(obj,i,obj.columns[j].id).toString().replace(/[\r\n]/g," ").replace(/"/g, q1).replace(/\s+/g, " ")+q; }; w.write(s+String.fromCharCode(13,10)+"<br id=0>"); }; if(obj.next_page!==null){f(obj.next_page)}else{w.write("</div>")}; }; };xh.open("GET",u,true);xh.send();};
0
13
13 Kommentare
Kristen Vales
Awesome! Thanks Serge!
@Deniel, can you share your modified script so I can export ticket descriptions as well?
0
Deniel Evanse
Bookmarklet is a great idea!
I have slightly modified your script. Now I can export ticket descriptions, which I can not by standard way.
0
Leon Weber
Thanks Serge! It works great.
0
Post ist für Kommentare geschlossen.