Preview count giving unexpected result

5 Comments

  • Nicole - Community Manager
    Comment actions Permalink

    Hey Dom - 

    I've pinged one of our resident API experts; hopefully someone from the community will jump in here and if not, we'll see if we can get this sorted out for you. 

    0
  • Dwight Bussman
    Comment actions Permalink

    HeyO Dom,

    There are a few reasons that this API request might return fewer tickets than expected:

    The cause that I see most frequently is the status of the ticket: Closed tickets will show in views, but Archived tickets will not. Once a ticket has been closed for 120 days it is automatically archived. If you open up one of the tickets that's excluded from the view, I suspect you might see the phrase "This is an archived ticket." As such, it can be located by search, but would not be returned by views for performance reasons.

    Another common reason for a view returning fewer than the expected number of tickets has to do with the permissions of the user making the API request: it should only return tickets that a given user has permissions to access. This could be affected by the role of the user whose credentials are being used to run this API call.

    The Preview function that you're calling into is not designed to return all of the tickets for a given view, but rather a sample. I'm afraid I don't know what the limit is, but in testing within my own account I haven't seen more than 20 tickets returned by a preview. If you're really curious on this limit, I'd be happy to look into it.

    Finally, it's possible that the Organization of a given customer changed after some of their tickets had already been closed. Closed tickets cannot be modified, so the organization property of the ticket itself is not updated to reflect the requester's organization.

    If you're looking to get a count of the number of tickets belonging to a given organization, I would recommend using the search API instead. Something along the lines of: 

        "api/v2/search.json?query=type:ticket organization_id:1234567890" 

    Please let us know if this helps to answer your question! If not, I'd be happy to create a ticket to look into this issue further (or you could do so by writing to support@zendesk.com).

    Thanks!

    0
  • Dom Latter
    Comment actions Permalink

    Hey Dwight, thanks for the comprehensive reply.  In our case it appears to be the archived tickets issue.  And it might be that we do actually want to ignore archived tickets - this is going in to part of an end-customer "manage my account" style page.  So perhaps we do only want "recent tickets" rather than for all time - because over the years that number is just going to grow and grow and that doesn't look too great.  But in that case when they click the link on to the next page (which lists individual tickets by subject line, date etc) then we want only non-archived tickets at that point (with a tick-box option to get archived tickets as well).  But there doesn't seem anything in the search API to restrict the search, nor does the archive status seem to be in the ticket data returned by the search.  So in our case it seems that the only thing we can do is use search to get the all time ticket count (which might not be what we want).

    0
  • Dwight Bussman
    Comment actions Permalink

    HeyO Dom,

    Sadly, you're correct: our search allows for restriction based on status, but because archived tickets are still technically in a "Closed" status, that sort of granularity isn't available. In trying to think of another workaround, it should be possible to construct a search which looks at the date the ticket was last updated and returns only those tickets that have been updated within the last 120 days, which would capture most tickets, but has the potential to miss tickets if they remain untouched in an un-solved status for longer than 120 days. Again, it feels like a workaround for something that might be better handled natively within our product. For more information on how to scope that search to a particular timeframe, please see this article.

    I went looking through our Product Feedback forum for other folks who might've requested similar functionality and found a comment on this post related to articles which feels very similar to what you're after for tickets. I would strongly encourage you to either comment on that feature request, or post a new request that helps to better clarify exactly what you're looking for. I'm happy to discuss this with our product folks as well, but posting to that Product Feedback forum is the best way to get visibility to that issue as it allows other users to vote in support of your idea which lends it greater weight in the consideration of our product managers.

    Hopefully this is helpful! I'd love to see a simpler method for identifying non-archived tickets via search or possibly a filter on the tickets endpoint. Again, if you'd like to start a ticket for our conversation, I'd be happy to do so to continue this in a more private venue to look into things specific to your account if need be.

    0
  • Dom Latter
    Comment actions Permalink

    Okay.  For now we will just give the all-time total number of tickets by using search.json:

    search.json?page=199999&per_page=1

    means that no actual tickets are returned...

    I will check with the people paying for this whether they want to refer to only recent tickets or whatever.  But really there should be consistency between these two aspects of Zendesk - either allow search to filter out archived tickets, and / or have the preview include all tickets.

    0

Please sign in to leave a comment.

Powered by Zendesk