Get Records From Zoho Inventory

Get Records From Zoho Inventory

Description

The zoho.inventory.getRecords task fetches the records from the specified module of Zoho Inventory.

Syntax

<response> = zoho.inventory.getRecords(<module>, <org_id>, [<criteria_map>], [<connection>]);
where:

 

ParamsData typeDescription

<response>

KEY-VALUE

The details of the list of all the records that will be fetched from the specified Zoho Inventory module.

<module>

TEXT

The module from which the records need to be fetched.

Allowed Values:

  • Contacts
  • PurchaseOrders
  • Bills
  • SalesOrders
  • CompositeItems
  • Items
  • Invoices
  • Packages (not supported in Zoho Creator)

<org_id>

TEXT

The organization ID of the account from which the records need to be fetched. 

Note: Learn how to fetch organization ID from the UI and from the response of zoho.inventory.getOrganization task.

<criteria_map>

(optional)

KEY-VALUE

The search criteria. The keys to this parameter are provided as specified in the Zoho Inventory API.

<connection>

(optional)

TEXT

The name of the connection.

Note: This parameter is not applicable to Zoho Creator and mandatory in Zoho Cliq.

Example 1: Fetch all records from the specified module

The following script fetches all the records from the Zoho Inventory module - Invoice:

 response = zoho.inventory.getRecords("invoices", "58XXXX49");

where:

response
The KEY-VALUE response returned by Zoho Inventory. It represents the details of the records that will be fetched from the specified Zoho Inventory module.
"invoice"
The TEXT that represents the module from which the records need to be fetched.
"58XXXX49"
The TEXT that represents the organization ID of the account from which the records need to be fetched.

Example 2: Fetch all the records that satisfy the specified criteria

The following script fetches the records from the Zoho Inventory module - Invoices that have the value - Kate in the field - customer_name:

 query_param = Map();
 query_param.put("customer_name", "Kate");
 
 response = zoho.inventory.getRecords("invoices", "58XXXX49", query_param);

where:

query_param
The KEY-VALUE variable that holds the query values.

Response Format

Success Response

  • The success response will be returned in the following format:

      {
      "code":0,
      "message":"success",
      "invoices":
      [
      {
      "invoice_id":"4787XXXXXXXXX9051",
      "ach_payment_initiated":false,
      "zcrm_potential_id":"",
      "zcrm_potential_name":"",
      "customer_name":"Kate",
      "customer_id":"4787XXXXXXXXX8022",
      "company_name":"",
      "status":"draft",
      "color_code":"",
      "current_sub_status_id":"",
      "current_sub_status":"draft",
      "invoice_number":"INV-000002",
      "reference_number":"",
      "date":"2019-08-29",
      "due_date":"2019-08-29",
      "due_days":"",
      "currency_id":"4787XXXXXXXXX0099",
      "schedule_time":"",
      "currency_code":"INR",
      "is_pre_gst":false,
      "tax_source":"",
      "template_type":"",
      "no_of_copies":1,
      "show_no_of_copies":true,
      "is_viewed_by_client":false,
      "has_attachment":false,
      "client_viewed_time":"",
      "type":"invoice",
      "project_name":"",
      "total":1850.0,
      "balance":1850.0,
      "created_time":"2019-08-29T17:15:03+0530",
      "last_modified_time":"2019-08-29T17:15:03+0530",
      "is_emailed":false,
      "reminders_sent":0,
      "last_reminder_sent_date":"",
      "payment_expected_date":"",
      "last_payment_date":"",
      "custom_fields":[],
      "custom_field_hash":{},
      "template_id":"",
      "documents":"",
      "salesperson_id":"",
      "salesperson_name":"",
      "shipping_charge":0.0,
      "adjustment":0.0,
      "write_off_amount":0.0,
      "exchange_rate":0.0
      },
      {
      "invoice_id":"4787XXXXXXXXX9018",
      "ach_payment_initiated":false,
      "zcrm_potential_id":"",
      "zcrm_potential_name":"",
      "customer_name":"Shawn",
      "customer_id":"4787XXXXXXXXX8001",
      "company_name":"",
      "status":"draft",
      "color_code":"",
      "current_sub_status_id":"",
      "current_sub_status":"draft",
      "invoice_number":"INV-000001",
      "reference_number":"",
      "date":"2019-08-29",
      "due_date":"2019-08-29",
      "due_days":"",
      "currency_id":"4787XXXXXXXXX0099",
      "schedule_time":"",
      "currency_code":"INR",
      "is_pre_gst":false,
      "tax_source":"",
      "template_type":"",
      "no_of_copies":1,
      "show_no_of_copies":true,
      "is_viewed_by_client":false,
      "has_attachment":false,
      "client_viewed_time":"",
      "type":"invoice",
      "project_name":"",
      "total":1550.0,
      "balance":1550.0,
      "created_time":"2019-08-29T17:11:13+0530",
      "last_modified_time":"2019-08-29T17:11:13+0530",
      "is_emailed":false,
      "reminders_sent":0,
      "last_reminder_sent_date":"",
      "payment_expected_date":"",
      "last_payment_date":"",
      "custom_fields":[],
      "custom_field_hash":{},
      "template_id":"",
      "documents":"",
      "salesperson_id":"",
      "salesperson_name":"",
      "shipping_charge":0.0,
      "adjustment":0.0,
      "write_off_amount":0.0,
      "exchange_rate":0.0
      }
      ],
      "page_context":
      {"page":1,
      "per_page":200,
      "has_more_page":false,
      "report_name":"Invoices",
      "applied_filter":"Status.All",
      "sort_column":"created_time",
      "sort_order":"D"
      },
      "instrumentation":
      {"query_execution_time":116,
      "request_handling_time":530,
      "response_write_time":170,
      "page_context_write_time":1
      }
      }

To fetch the IDs of the records, execute the following snippet:

var = <response_variable>.get("<module_name>"); 
// example for <module_name> is invoices
for each var1 in var
  { 
    info var1.get("<module_name>_id"); 
   // example for <module_name>_id is invoice_id 
  }

Failure Response

  • The failure response for incorrect organization ID will be returned in the following format:

      {
      "code": 6041,
      "message": "This user is not associated with the CompanyID/CompanyName: 58XXXX50."
      }

Related Links

Share this post : FacebookTwitter

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

Write to us: support@zohodeluge.com