Creator Help

Fetch Records from Zoho Books

 Overview

Using zoho.books.getRecords() Deluge task in Zoho Creator, you can fetch related records from Zoho Books. You can make use of different workflow options in Zoho Creator to automate this process . Fetch records from contacts, invoices and payments modules in Zoho Books, using a search keyword. For example, execute "form actions" in Zoho Creator using the search keyword to fetch a contact from Zoho Books. Or configure a scheduler in Zoho Creator to fetch a particular invoice from Zoho Books.

 Supported Modules

  • Contacts
  • Invoices
  • Customerpayments
  • Items
  • Estimates
  • RecurringInvoices
  • Expenses

 Syntax

<response> = zoho.books.getRecords (<module>, <orgID>,<search>);

where,
<response> is the map variable returned as response. It contains the details of the newly created record.

<module> is the name of the Zoho Books' module where the record needs to be updated. For example, "Contacts" refers to the Contacts module. The Zoho Books' modules that are supported by Creator are "Contacts", "Invoices", and "Customer Payments".

<orgID> refers to your organization ID as specified in Zoho Books. To know your organization ID, click on <YourOrganizationName> > Manage Organizations, from the top-right corner of your Zoho Books Home page.

<search> includes the label name in the Zoho Books' module and its corresponding keyword that we search for. For example, contact_name=zoho. Here contact_name is the label name in Zoho Books' module and "zoho" is its value using which the search is performed.

Note:

  • All the parameters listed above are mandatory.  
  • "startswith" and "contains" are two additional variants that can be used in the search parameter. For example, contact_name_startswith and contact_name_contains.

 Example

1) Fetch a contact from Zoho Books using search

In this example, a record is fetched from Zoho Books' Contacts module by adding code to a Zoho Creator form. Upon submission of the form, the record pertaining to the specified search keyword gets fetched.

  • Add the following scipt in the "on Success" section of your Zoho Creator form
response = zoho.books.getRecords("contacts", "12345678","contact_name=john");
  • Submitting the form will fetch the record with contact_name "John" from your Zoho Books.

where,
contacts is the name of the Zoho Books' Module from where the record needs to be fetched.
12345678 is a sample organization ID. Replace it with your organization ID
contact_name=john is the search parameter where contact_name is the label name in Zoho Books' module and "john" is its value using which the search is performed.

 Response Format

The following code for getRecords() task,

response = zoho.books.getRecords("contacts", "35201411","contact_name=Zoho Creator"); 
info response;

yields the following response format,

{
"message":"success",
"page_context":{
"search_criteria":[
{
"search_text":"Zoho Creator",
"comparator":"equal",
"column_name":"contact_name"
}
],
"per_page":200,
"sort_column":"contact_name",
"has_more_page":false,
"page":1,
"report_name":"Contacts",
"applied_filter":"Status.All",
"sort_order":"A"
},
"code":0,
"contacts":[
{
"phone":"",
"currency_id":"1782000000000099",
"payment_terms":0,
"contact_id":"1782000000045001",
"status":"active",
"payment_terms_label":"Due On Receipt",
"is_linked_with_zohocrm":false,
"outstanding_receivable_amount":0,
"first_name":"",
"unused_credits_payable_amount":0,
"source":"api",
"email":"",
"unused_credits_receivable_amount":0,
"company_name":"",
"outstanding_payable_amount":0,
"last_modified_time":"2015-02-18T15:01:39+0530",
"last_name":"",
"contact_name":"Zoho Creator",
"contact_type":"none",
"created_time":"2015-02-18T15:01:39+0530",
"currency_code":"INR",
"mobile":""
}
]
}

If the given query does not yield any matched results, the response will be in the following format:

Response for - No match for the given query

{
"message":"success",
"page_context":{
"search_criteria":[
{
"search_text":"ParkaS",
"comparator":"equal",
"column_name":"contact_name"
}
],
"per_page":200,
"sort_column":"contact_name",
"has_more_page":false,
"page":1,
"report_name":"Contacts",
"applied_filter":"Status.All",
"sort_order":"A"
},
"code":0,
"contacts":[

]
}

Share this post : FacebookTwitter

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

Write to us: support@zohocreator.com