Unable to Filter by CustomStringField1 in workItemsFilter

Officially Answered

Comments

7 comments

  • Avatar
    Vanja Pletikosić

    Hello Vincent,

    Thank you for reaching out to us.
    Please try to use $filter to filter out work items without a custom field, like this:

    &$filter=CustomStringField1 ne null

    And since the workItemsHierarchyAllLevels endpoint requires a workItemsFilter, then please try to use a different one.
    You can use it to specify a Project, in this way:

    &workItemsFilter=System_TeamProject eq 'Project1'


    Best regards,
    Vanja

     

    0
    Comment actions Permalink
  • Avatar
    Vincent Fortin

    Hello Vanja,

    Thanks for the answer, unfortunately my issue is that &workItemsFilter does not seem to work with custom fields. Is there a way to filter out results from workItemsHierarchyAllLevels with workItemsFilter using a custom field?

    Here's what I am currently doing and thought would work, but doesn't:

    https://<org>.timehub.7pace.com/api/odata/v3.2/workItemsHierarchyAllLevels?$select=CustomStringField1&customFields=Custom.Year&workItemsFilter=CustomStringField1 ne null

    Although I made sure to select the custom field and indicate to the API which field CustomStringField1 should correspond to. It instead returns this error:

    "statusCode": 500,
        "errorCode": "UnexpectedError",
        "errorDescription": "Unexpected error occurred",
        "fields": {
          "originalMessage": "Could not find a property named 'CustomStringField1' on type 'Timetracker.Entities.Models.WorkItemCacheEntry'.",l

    Cordially

    0
    Comment actions Permalink
  • Avatar
    Vincent Fortin

    Also, while we're at it. The workItemsHierarchyAllLevels endpoint does not seem to return a TrackedTotal value that takes into consideration the time inputted on it's children work items. Is there a way to do so?

    TrackedTotal is always equal to TrackedItself even though I have Product Backlog Items as children of my Feature, and these PBIs have time on them.

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Vanja Pletikosić

    Hi Vincent,

    You will have to use $filter instead of workItemsFilter:

    &$filter=CustomStringField1 ne null


    Best regards,
    Vanja

     

     

    0
    Comment actions Permalink
  • Avatar
    Vincent Fortin

    Hello Vanja,

    Ok interesting, that works indeed, thanks!

    FYI for anyone else stumbling across this thread here's what my query ended up looking like, showing only the elements relevant to my initial question:

    https://<org>.timehub.7pace.com/api/odata/v3.2/workItemsHierarchyAllLevels?$select=CustomStringField1&customFields=Custom.Year&$filter=CustomStringField1 ne null&workItemsFilter=System_Id gt 0
    0
    Comment actions Permalink
  • Avatar
    Vanja Pletikosić

    Hi Vincent,

    Good to hear that it works.
    However, one note about you using the workItemsFilter in this way "&workItemsFilter=System_Id gt 0" - this prefilter was designed to narrow down the returned results in order to avoid hiting API limits. In the way it is constructed here, you will still get all results for all work items. And the workItemsHierarchyAllLevels endpoint is the most heaviest on the API load, since it queries all work items with their entire hierarchy, if left unfiltered.

    Could you please change the workItemsFilter to filter by type, or Project, or Area Path?

    Best regards,
    Vanja

    0
    Comment actions Permalink
  • Avatar
    Vincent Fortin

    Hello Vanja,

    Oh yes don't worry I just put the first filter that came to mind since I wanted to test $filter, it's not actually what I ended up using. I was only looking at the first page of results through Postman while investigating which API calls we should be using for our PowerBI report.

    Thanks

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk