Build your first Support app - Part 4: Getting data

Have more questions? Submit a request

9 Comments

  • Ignacio De La Llave Lorenzo
    Comment actions Permalink

    Hello,

    I'm working in my first app in Zendesk and I have one question that I can't find in the documentation:

    Basically I want the code to react to changes in the ticket.

    For example, my app is showing a modal window when the ticket's organization has a custom field checked but I would want for that modal window to show also when the requester of the ticket (and so the organization) changes (right now you need to refresh the window to see it).

    If you could point me in the right direction on how to listen to these changes I would greatly appreciate it.

    Regards,

    0
  • Rene Herrera
    Comment actions Permalink

    Hi Charles Nadeau, I am following your tutorial about Build your first Support app, Part 4.

    How can I add to my app a .js code that tells me the CCs users in a ticket?

     

     

    0
  • Bryan Flynn
    Comment actions Permalink

    Hi Rene,

    Depending on what you're doing, you'll want to look at either client.get('ticket.collaborators') or the GET /api/v2/tickets/{id}/collaborators.json API. Hope this gets you going!

    0
  • Rene Herrera
    Comment actions Permalink

    Hi Bryan Flynn, how can i add the client.get('ticket.collaborators') function to the same code in the Part 4  of building your first support app?

    thanks

    0
  • Bryan Flynn
    Comment actions Permalink

    Hi Rene. Where you put the code and how you process the data it returns will be up to you. The above code is just an example and isn't production ready. You'll need to customize it to meet your particular needs.

    That said, something like the below should work. You'll have to modify your own code as needed -- this is just pseudo code and an example:

    function requestUserInfo(client, id) {
    ...
    client.request(settings).then( (data) => {
    return client.get('ticket.collaborators').then((collabData) => {
    showInfo(data, collabData);
    })
    })
    ...

     

    0
  • Boris Yurchenko
    Comment actions Permalink

    I am trying to get two tables, one after the other. Table 1 gets info about the requester, table 2 gets info about the current agent logged in.

    My issue is that if I use two adjusted tables, one generated after the other one, the second table would replace the first one. And vice versa, basically at random.

    I created two different scripts:

    <script id="requester-template" type="text/x-handlebars-template">
    <script id="agent-template" type="text/x-handlebars-template">

    Each of them adds different information, but that gets replaced.

    Any advice would be appreciated.

    0
  • Bryan Flynn
    Comment actions Permalink

    Hi Boris -- without seeing your code, perhaps you are replacing a "div" with the requester's information, then immediately replacing that same "div" with agent information? OR, maybe you're not chaining/nesting the client.get JavaScript Promise calls correctly?

    If you look at this Github gist, you can see it getting requester information, then agent information, then populating a Handlebar template and displaying that information in two different tables (both tables contained in one template).

    I hope this helps. If you want to read a bit more about JavaScript Promises and how they behave in the context of Zendesk, check out this article: JavaScript Promises — a Zendesk Introduction

    Good luck!

    0
  • Boris Yurchenko
    Comment actions Permalink

    Bryan,

    The code snippet you provided made it really clear. It looks like I used a wrong approach to populating the tables. Now that I customized and extended the example code you provided I can get everything I need.

    Thanks a lot!

    0
  • Bryan Flynn
    Comment actions Permalink

    You're welcome Boris -- glad it worked out!

    0

Please sign in to leave a comment.

Powered by Zendesk