Search code examples
attaskworkfront-api

WorkFront (AtTask) API - Search Custom Fields by Value


I'm working with the WorkFront API and I have been able to query all projects that have a custom field that I'm searching by, and then further filter them by whether or not they are null with a GET request like so:

https://<COMPANY>.attask-ondemand.com/attask/api/v5.0/proj/search?DE:<CUSTOM_FIELD_NAME>_Mod=notnull&fields=DE:<CUSTOM_FIELD_NAME>&apiKey=<API_KEY>

This Custom Field is just a set of radios with only two valid options: "Yes" and "No" (otherwise "null" if not set). Is there a way that I can query only those projects with a "Yes" value this Custom Field using the API?


Solution

  • Absolutely, you're already very close. Using your example, you could execute the following:

    https://<COMPANY>.attask-ondemand.com/attask/api/v5.0/proj/search?DE:<CUSTOM_FIELD_NAME>=Yes&apiKey=<API_KEY>
    

    You don't need to explicitly ask for the custom field to be provided (fields=DE:xxxxx) because it's already a part of the query and so it will always be returned to you.

    FYI the API is now running v6.0 so you can update your search to use that. Certain functions may only work (or may work better) using the newest version.

    Edit: It doesn't matter for this example, but be aware that you can give your custom fields names that will cause problems with the API (some special characters like &) so you can always set the value of the fields to something different than the display name, such as setting Yes to 1 and No to 0.