Introduction
While working hard on Roun Robin App, we always find some time to make your everyday work with Zendesk even nicer.
Perhaps you are faced with the problem of CSV file request frequency limit. To work around it, we use a bookmarklet which receives the data via Zendesk API and saves them to a CSV file.
You can get the bookmarklet HERE. It's open source and FREE. Enjoy!
How it works
This video shows how it works.
Source code
Following is the bookmarklet js code. Feel free to modify it for your tasks.
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://r2.roundrobin-assignment.com/?utm\\_source=internal&utm\\_medium=serv&utm\\_content=csv&utm\\_campaign=promo\\_serv'](http://r2.roundrobin-assignment.com/?utm\_source=internal&utm\_medium=serv&utm\_content=csv&utm\_campaign=promo\_serv'); target=' \_blank'>Created by Round Robin App team</a> (<a href=' [https://twitter.com/RoundRobinApp'](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}; 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 s="id"; 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; for (var j = 0; j < obj.columns.length; j++) { s += ","+q+gv(obj,i,obj.columns[j].id)+q; }; w.write(s.replace(/(\n)/g," ")+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 Comments