Expand my Community achievements bar.

Don’t miss the Workfront AMA: System Smarts & Strategic Starts! Ask your questions about keeping Workfront running smoothly, planning enhancements, reporting, or adoption, and get practical insights from Adobe experts.

Combine OR and AND operators in call to search API

Avatar

Level 4

Hi All,

I'm trying to use the PROJ/search API endpoint to find projects that meet the following criteria:

(status is not CPL AND status is not DED AND enteredByID = 111) OR (status is not CPL AND status is not DED AND enteredByID = 222)

I know that the API takes the filters in a text mode like manner, so here's my attempt for the 1st part (line breaks added here only for easier reading):

PROJ/search?$$LIMIT=2000&fields=ID,name,status,enteredBy:name
&status=CPL
&status_Mod=ne
&AND:1:status=DED
&AND:1:status_Mod=ne
&enteredByID=111

How would I add the 2nd part of the filters?

I'm trying this:

PROJ/search?$$LIMIT=2000&fields=ID,name,status,enteredBy:name
&status=CPL
&status_Mod=ne
&AND:1:status=DED
&AND:1:status_Mod=ne
&enteredByID=111
&OR:1:status=CPL
&OR:1:status_Mod=ne
&OR:1:AND:2:status=DED
&OR:1:AND:2:status_Mod=ne
&OR:1:enteredByID=222

But it gives me an error response:

422 Unprocessable Entity - APIModel V19_0 does not support field AND (Project)

I appreciate if anyone can share any idea.

Cheers,
Tibor

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Reply

Avatar

Level 4

Hi @tibormolnar,

 

We had a similar logic implemented some time ago.

 

Some of the things to consider before we dive into solution

  1. attask/api-internal should be used as API version (Select map and copy paste this option)
  2. Add conditions as query string (it makes your life easier as you can create this text in a variable and also can modify it independently of request module)

This is example logic for query string and how it should be formatted (also including DATA extension fields)

 

{"qs":[
{"key":"fields", "value":"ID,project:name,opTask:name,DE:calc field,currentVersion:ext"},
{"key":"AND:1:DE:calc field", "value":"DESIRED_FIELD_VALUE"},
{"key":"AND:2:OR:1:DE:calc expiration date_Mod", "value":"gt"},
{"key":"AND:2:OR:1:DE:calc expiration date", "value":"{{now}}"},
{"key":"AND:2:OR:2:DE:calc expiration date_Mod", "value":"isblank"},
{"key":"$$LIMIT", "value":"ADD_IF_NEEDED"},
{"key":"$$FIRST", "value":"ADD_IF_NEEDED"}
]}

 

 

Hopefully this helps. Please let me know if you have any additional questions.

 

Best regards,
Ivan Bebek