Fetch Records

Get records from Zoho Invoice

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,

ParamsData typeDescription

<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.

ContactsInvoicesCustomer PaymentsItems
EstimatesExpensesExpenseCategory

Projects

(applicable to all Zoho services except Zoho Creator)

<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:
Click here and go to <moduleName> -> list <moduleName>. All query params listed there are applicable as keys with the required values.

When the param is used as a string:
Click here and go to <moduleName> -> list <moduleName> -> filter_by for more information on the applicable values for this param.

<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"
is the TEXT that represents the module from which the records need to be fetched
"53XXXXXX"
is the TEXT that represents the organization ID of the Zoho Invoice account from which the records need to be fetched

​​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 
is the KEY-VALUE variable that holds the search values
 filter_by  Status.Active 
are the TEXT that represents the query params specified in Zoho Invoice's API

​​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 
is the KEY-VALUE variable that holds the search values
 name  Pendrive
are the TEXT that represents the query params specified in Zoho Invoice's API

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:

var1 = <response_variable>.get("<module_name>");
// 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"
     }

Related Links

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com