How can I get Time Tracking data via the API?

Return to top
Have more questions? Submit a request

15 Comments

  • Adam Weiss

    If you're looking for significantly more detailed time data, you can find it via Ticket Audits: https://developer.zendesk.com/rest_api/docs/core/ticket_audits

    Note that it's somewhat buried...

    {
      "id": <AUDIT ID>
    ...
      "events": [
        {
          "id": <EVENT ID>
          "type": "Change",
          "value": 360, (this is the NEW TOTAL)
          "field_name": <YOUR TOTAL TIME SPENT FIELD ID>,
          "previous_value": 0 (this is the value it was before)
        },
    ...
      ]
    ...
    }

    Want to know how much time for each "event"? Just subtract "value" from "previous_value".

    1
  • Nicole S.
    Zendesk Community Team

    Thanks for the info, Adam!

    0
  • Edward Ionescu

    How do you get the date and id/name of the person who did that time entry? 

    I can get the time, but can't tell for whom it comes...

    How can you link Time Tracking app field with ticket_audits? What's the key field that links them? 

    Thank you

    0
  • Adam Weiss

    Edward,

    It looks to me like you're pulling the field info--not the audit.

    The audit "events" contains the "author_id". Use:

    https://[DOMAIN].zendesk.com/api/v2/tickets/[TICKET]/audits.json

    Then check out my notes above.

    Adam

     

     

    Adam

    0
  • Edward Ionescu

    Hi Adam,

    Thank you very much for the quick answer, much appreciated. 
    Indeed, that screenshot is from the field info, I was wondering where it says it's a Time Tracking object. 

    The author_id is the one that created the audits entry, so he also created the Time Tracking entry on the date_time. Is that correct? 

    0
  • Adam Weiss

    Yep, sure is!

    1
  • Edward Ionescu

    Many thanks :) 

    0
  • Andrew J
    Community Moderator

    I'm wanting to hook the Time Tracking App into another modal on ticket closure. Problem being that there can only be one modal at a time (is this correct? how would it display otherwise?)

    0
  • Bryan - Community Manager
    Zendesk Developer Support

    Hi Andrew,

    For apps that were written in Apps framework v2, there can only be one modal open at a time.

    If multiple apps all have ticket.save events that bring up modals (such as the Time Tracking app) then when one modal from one apps is closed, the next modal from the next app in the ticket.save event chain will open.

    If this doesn't get you going in the right direction, please share any additional use-case details and maybe some other way can be found.

    0
  • Andrew J
    Community Moderator

    Thanks Bryan, can I email you? We're wanting to do a number of apps that pop a modal on close or save. Chains of modals is going to be really messy and annoying for agents. I'm hoping to find a way to display all at once and have one button affect all.
    Another possibility is to have a central app that pulls in the requirements of the other installed apps, so that they aren't popping their own modal... Your thoughts?

    0
  • Bryan - Community Manager
    Zendesk Developer Support

    I'll open a ticket on your behalf Andrew and we can talk on the side. It sounds like the last idea of pulling in requirements of other installed apps is the way to go (but would require that you control those apps as you can't suppress ticket.save events or modals from other apps).

    0
  • Jason Wehling

    So I can get the "Total time spent" off the ticket via a custom field. And I can see through this thread that, using Ticket Audit events, I can get all the "Change" events which contain each time tracking entry value, and per authorId (from the parent Audit object). All that's great, and I have that working. What I can't figure out is how to determine _when_ those hours were logged. Specifically, I want to know how many hours were logged by agents in a period of time (last week, or last month), and I can't seem to figure that out. What am I missing? Any assistance is appreciated. Thanks.

    0
  • Adam Weiss

    There should be a "created_at" field in each of the audits.

    0
  • Jeff Callahan

    Would it be possible to build a Trigger and a URL Post target to send the Event data in Realtime to another system (i.e. Salesforce).

    We have a Time Entry package in Salesforce where we can configure a an interface.  I would like to use this information to help build my Agents Timesheets  

    0
  • Dwight Bussman
    Zendesk team member

    HeyO Jeff,

    Our current SFDC integration does basically this exact thing by leveraging a custom ticket object. For more information on configuring this feature of the integration, please see https://support.zendesk.com/hc/en-us/articles/203660006 

    More generally, this workflow should definitely be possible, although I'd recommend the use of an HTTP target (rather than the URL target) because it's easier to see/manipulate the format of the data being sent. For more information about this type of workflow, please see https://support.zendesk.com/hc/en-us/articles/204890268-Creating-webhooks-with-the-HTTP-target

    Hopefully this helps to answer your question!

    0

Please sign in to leave a comment.

Powered by Zendesk