Zoho Reports API allows you to apply filter criteria while you execute the various actions. When you apply a criteria, the action will be performed only on the data that matches the filter criteria given.
You can apply criteria as part of the following API actions:
The filter criteria has to be passed as a parameter, named ZOHO_CRITERIA, to the action request. This should be part of the body of the POST request.
The filter criteria that is passed as part of the request, should follow the same format as that of the SQL SELECT WHERE clause. The generalized format of a simple criteria is given below:
(<column name/SQL expression/SQL function calls> <relational operator> <value/column name/SQL expression/SQL function calls>)
(("Department"='Finance' and "Salary" < 9000) or ("Department"='Admin' and "Salary" < 8000))
The criteria follows the SQL SELECT WHERE condition like format. You could also use SQL in-built functions as part of the criteria. These built-in functions should be the functions supported by any of Oracle, MS SQL Server, MySQL, DB2, Sybase, ANSI SQL, Informix and PostgreSQL databases.
||Refers to the name of the column in table or query table on which you are applying a criteria
You could provide any valid SQL Expression.
The above expression subracts the value in the "Cost" column from value in the "Sales" column. You could use any of the Arithmetic operator supported in an SQL SELECT WHERE clause.
Supported Arithmetic Operators:
+, -, *, /
|SQL Function call
Oracle, MS SQL Server, MySQL, DB2, Sybase, ANSI SQL, Informix and PostgreSQL databases
Eg.: year(date_column) = 2008
Note: All supported in-built function from different databases will be documented soon.
This could be any of the relational operators supported in an SQL SELECT WHERE clause.
Supported Relational Operators:
- NOT LIKE
- NOT IN
Refers to the exact value to match
Eg.: "Department" = 'Finance"
here 'Finance' is a literal value to match.
Notes for Criteria formation:
You can combine any number of criteria defined in the above specified format using Logical Operators like AND and OR to form complex criteria, the same way as in SQL SELECT WHERE
clause. Also use Braces '()' to group the criteria for ordering.
- Enclose string literals (ie values) in single quotes.
Enclose column names in double quotes.
- Eg.: ("Date Of Birth" = '2007-01-31 00:00:00')
Currency symbols (or) percent symbol can't be used in criteria
- Eg.: currency_column = 75.66 is valid
- Eg.: percent_column = 100 is valid
- currency_column = 75.66$ (or) percent_column = 100% is not valid
Refer to the SQL SELECT WHERE clause documentation of any database that we support, to know more on how to construct the filter criteria.
A sample delete request that deletes all the rows that match the criteria "Department"= 'Finance' is given below.
Data Sent as POST parameters.
ZOHO_CRITERIA is encoded for the url format. Unencoded value is provided below.
ZOHO_CRITERIA=("Department" = 'Finance')