workfront-api

How to integrate nested "AND", "OR" conditions to the "WorkFront" query


I have a form where the user can generate any condition on the basis of that condition our system will fetch data from WorkFront.

Query is something like that :

SELECT `name` FROM Project where name = 'test' AND (status = 1 OR status = 2)

The query will be generated by the user so it may be more complicated its depend on the user.

So is there any way to run this query or convert this to a form understood by work front.

I have read all filters provided by workfront but there is no success as the available filter are unable to fulfill my requirement.


Solution

  • Workfront's filters are not very advanced and I suspect that a complex query would not be able to be implemented completely within the constraints of the API. Your query is possible with:

    GET https://<url>.my.workfront.com/attask/api/v9.0/PROJ/search?name=<name>&status=<status1>,<status2>&apiKey=<key>
    

    However, this query is possible only because of the relative simplicity and the fact that your nested condition is really just two valid values of a single search (two statuses) that can be expressed with commas. If you had a more complex query with each nested search using at least one unique value, like

    SELECT 'name' from PROJECT where (name = 'test' AND status = 'complete') OR (percentageComplete >= 75 AND status = 'blocked')
    

    At least, I can't think of a way do to that within Workfront...that doesn't mean that there really is no way to do it.

    Nevertheless, when I need a complex query I simply build it piecewise and then combine the data in my application. For example, in the above case I'd just run the two queries individually and then combine the two result sets (since it's an OR) within my code and present a unified dataset to my user so they're none the wiser that it was really multiple queries to Workfront. That is the solution that I'd suggest you use.