Recent searches
No recent searches
Export view to CSV file without 10 min limit
Posted Apr 10, 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 comments
Leon Weber
Thanks Serge! It works great.
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
Kristen Vales
Awesome! Thanks Serge!
@Deniel, can you share your modified script so I can export ticket descriptions as well?
0
Serge
Thanks!
I'm glad you liked it.
Following is the script code with "description".
0
Serge
Thanks! I'm glad you liked it.
The script code with "description" is here.
0
Alexander Garden
The addition of Description fields to the CSV is exactly what we needed to compile and efficiently distribute high volumes of user feedback to other departments.
Thank you Serge, and thank you Deniel.
0
Serge
@Alexander Thanks!
Last week we had found and fixed a bug in the code of this script. The double quote character was not escaped in Description field. All who are faced with the issue, please update your bookmarklet.
The fixed script is here.
0
Jennifer Rowe
thanks for the update, Serge!
0
Kristen Vales
Thanks for the update Serge!
0
BrianCoppola
This works well for me. Does anyone know how to or if it is possible to export the following:
1. all public comments, not just the original
2. links to attachements
Thanks,
Brian
0
Jessie Schutz
Hi Brian!
You can get this information using our API: https://developer.zendesk.com/
0
BrianCoppola
Hi Jessie,
Thanks for the info on the API - I have gone through it. Here is my goal - I want to export a specific view to a CSV, but with the public comments and the attachment link. I need those elements for my weekly review with the requestor.
The tool above is great because it dumps the view easily to a CSV, but does not have the other fields I need.
I can get the API to export my view to a CSV as well, but not with the custom fields.
Trying to find the best solution and I thought the above was the closest solution. Any ideas for me?
Brian
0
Jessie Schutz
Hi Brian!
If you're pulling the View itself via API it'll be subject to the same restrictions as the in-product tool.
What you want to do is actually pull the information via API completely independent of the View you created. The API contains all the endpoints you need to pull the exact set of tickets you need, along with the custom fields you want.
I'm afraid I don't have in-depth knowledge of how to accomplish so I can't personally give more guidance than that. But if you have further questions I can certainly find somebody to help you out!
0