Problems and Incident counts with Google Apps Script - integration template & guide

8 コメント

  • Brett - Community Manager

    This is fantastic! Thanks for taking the time to create this and share with everyone :)

  • Heather R

    I agree, this is fantastic! 

  • Justin Fenech

    Thanks! Happy to help.

  • Cyrup

    This is amazing, thanks!

  • Gareth Elsby

    Hey Justin,


    Great tool! I've taken a copy of this and I've been having a play around with it. I managed to create one to pull down organisations and support addresses. They work pretty good!

    function onOpen(){
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var menu = [
    {name: "Configure", functionName: "zendeskConfigure"},
    {name: "Get Agents", functionName: "getAgents"},
    {name: "Get Problems", functionName: "getProblems"},
    {name: "Get Organisations", functionName: "getOrganisations"},
    {name: "Get Support Addresses", functionName: "getSupportAddresses"},
    {name: "Get Triggers", functionName: "getTriggers"}
    ss.addMenu("Zendesk", menu);

    // Get all organisations
    function getOrganisations() {
    var resultId = 'organizations';
    var sheet = 'Organizations';
    var params = 'organizations.json';
    var fields = [ "id", "name", "domain_names","organization_fields" ];
    var result = getClient().request(params);

    spreadsheetDBSave(result, resultId, sheet, fields);

    // Get all Support addresses
    function getSupportAddresses() {
    var resultId = 'recipient_addresses';
    var sheet = 'Support Addresses';
    var params = 'recipient_addresses.json';
    var fields = [ "id", "name", "email", "default", "forwarding_status" ];
    var result = getClient().request(params);

    spreadsheetDBSave(result, resultId, sheet, fields);


    Could you think of a way to handle pagination on Organisations? I could only pull down the first 100 :(



  • Justin Fenech

    Hi Gareth,

    Apologies for the delayed reply. Pagination is something I really should have worked in, but I no longer have access to a zendesk account, and I'm waiting for my Zendesk developer account to be activated. If someone from Zendesk is reading this, hint hint.

    In the interim something like the following should work if you add it to the Libs/ file.
    This has not been tested and I am going off memory of how the api data was structured. 
    I have also tried to keep this compatible with the spreadsheetDBSave helper function by passing in the resultId and structuring the results data accordingly. 

    Client_.prototype.requestAll = function (uri, resultId) {
    var userProperties = this.authPropertyStore_;

    if (this.authService_) {
    if (this.authService_.hasAccess()) {
    var url = 'https://'
    .concat(userProperties.getProperty('subdomain'), '', uri);
    var results = {};
    results[resultId] = [];

    while(url) {
    var response = UrlFetchApp.fetch(url, {
    headers: {
    Authorization: 'Bearer ' + this.authService_.getAccessToken()
    var result = JSON.parse(response.getContentText());
    url = result.next_page;

    return results;
    } else {

    You should be able to call this new function like so:

    var result = getClient().requestAll(params, resultId);

    Hope this helps, let me know how you go.



  • Brett - Community Manager

    Thanks for sharing this Justin!

    I did want to follow-up with you as well regarding your developer account.

    I checked internally and as far as I can tell your account should be up and running.

    Can you confirm on your end?

  • Justin Fenech

    Hi Brett - always happy to help out when I have the time!

    I just logged in and you are correct; there is no longer a trial message and the account appears to be working correctly. Thank you for taking the time to look into this for me.




Powered by Zendesk