Get records from Zoho Invoice
Table of Contents
Note:
- Each time the zoho.invoice.getRecords integration task is executed, it triggers an API request in the back-end. This call is deducted from the external calls limit available for the service from which the task is executed, based on your pricing plan.
- Only actual executions that receive a response (whether success or failure) are counted, not the number of times the task appears in the script. For example, if zoho.invoice.getRecords integration task is placed inside a for each task that iterates five times, the number of external calls consumed will be five, even though the task appears only once in the script.
Overview
This task is used to fetch records from Zoho Invoice.
Syntax
<variable> = zoho.invoice.getRecords(<module_name>, <org_ID>, <search_map>, <searchText>, <sortColumn>, <connection>);
where,
| Params | Data type | Description | ||||||||
| <variable> | KEY-VALUE | specifies the response returned by Zoho Invoice. It represents the values of the record fetched from the specified module. | ||||||||
| <module_name> | TEXT | specifies the Zoho Invoice's module from which the records need to be fetched. Following are the applicable modules.
| ||||||||
| <org_ID> | TEXT | specifies the org ID of the account from where the records will be fetched. | ||||||||
<search_map> (optional) | KEY-VALUE (data type applicable for all Zoho services except Zoho Creator) TEXT | specifies the values based on which the records will be filteres. When the param is used as key-value: When the param is used as a string: | ||||||||
<searchText> (optional) | TEXT | Search for records based on field values. Click here and go to <moduleName> -> list <moduleName> -> search_text for more information on the applicable values for this param. | ||||||||
<sortColumn> (optional) | TEXT | Sort the records based on a field. Value for this param will vary depending on the module. Click here and go to <moduleName> -> list <moduleName> -> sort_column for more information on the applicable values for this param. | ||||||||
<connection>* (optional) | TEXT | specifies the name of the connection. *Note: This param is not supported when used in Zoho Creator. |
Example 1
The following script fetches records from the Zoho Invoice module - Items.
response = zoho.invoice.getRecords("Items", "53XXXXXX");
where,
"Items"
"53XXXXXX"
Example 2
The following script fetches records from the Zoho Invoice module - Items. Also, it filters the records to fetch only those with invoice status - Status.Active.
search_map = {"filter_by":"Status.Active"}; response = zoho.invoice.getRecords("Items", "53XXXXXX", search_map);
where,
search_map
filter_by Status.Active
Example 3
The following script fetches records from the Zoho Invoice module - Items. Also, it searches the records to fetch only those with the item name - Pendrive.
search_map = {"name":"Pendrive"}; response = zoho.invoice.getRecords("Items", "53XXXXXX", search_map);
where,
search_map
name Pendrive
Sample Response
The following is a sample success response
The success response returned is of the following format.
{
"code": 0,
"message": "success",
"page_context": {
"per_page": 200,
"sort_column": "rate",
"applied_filter": "Status.All",
"has_more_page": false,
"page": 1,
"report_name": "Items",
"sort_order": "A",
"search_criteria": [
{
"comparator": "equal",
"column_name": "name",
"search_text": "Pendrive"
}
]
},
"items": [
{
"created_time": "2019-01-02T19:33:12+0530",
"reorder_level": "",
"last_modified_time": "2019-02-09T14:34:43+0530",
"item_id": "30870XXXXXXXXXXXXX",
"tax_name": "",
"is_linked_with_zohocrm": true,
"purchase_rate": 400.0,
"description": "",
"item_name": "02-Mar-2018 06:03:12",
"has_attachment": false,
"source": "api",
"zcrm_product_id": "23033XXXXXXXXXXXXX",
"tax_id": "",
"purchase_description": "",
"image_name": "",
"unit": "",
"product_type": "goods",
"rate": 350.0,
"name": "Pendrive",
"tax_percentage": 0,
"sku": "",
"status": "active"
},
{
"created_time": "2018-03-02T19:35:43+0530",
"reorder_level": "",
"last_modified_time": "2018-06-29T14:34:44+0530",
"item_id": "30870XXXXXXXXXXXXX",
"tax_name": "",
"is_linked_with_zohocrm": true,
"purchase_rate": 600.0,
"description": "",
"item_name": "02-Mar-2018 06:05:43",
"has_attachment": false,
"source": "api",
"zcrm_product_id": "23033XXXXXXXXXXXXX",
"tax_id": "",
"purchase_description": "",
"image_name": "",
"unit": "",
"product_type": "goods",
"rate": 500.0,
"name": "Pendrive",
"tax_percentage": 0,
"sku": "",
"status": "active"
}
]
}
To fetch the IDs of the records, execute the following snippet:
// example for <module_name> is contacts
for each var2 in var1
{
info var2.get("<module_name>_id").toLong();
// example for <module_name>_id is contact_id
}
Failure Response
The failure response returned due to invalid organization ID is of the following format:
{
"code":6041,
"message":"This user is not associated with the CompanyID/CompanyName:63XX."
}The failure response returned returned due to invalid search parameter is of the following format:
{
"code":2,
"message":"Invalid value passed for filter_by"
}