Get Records using record ID

 Overview 

Using zoho.books.getRecordsByID() 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 the record ID. For example, execute "form actions" in Zoho Creator using the record ID 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.getRecordsByID(<module>, <orgID>,<contactID>);

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.

<contactID> pertains to the record id that needs to be fetched. Here it stands for contact ID.

Note:

  • All the parameters listed above are mandatory.

 Example

1) Fetch a contact from Zoho Books using Record ID

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 record ID gets fetched.

  • Add the following scipt in the "on Success" section of your Zoho Creator form.
response = zoho.books.getRecordsByID("contacts", "12345678","11111000000000001");
  • Submitting the form will fetch the record with ID "11111000000000001" 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.
11111000000000001 is the  record ID of the record that needs to be fetched

 Response Format

The following code for getRecordsByID() task,

response = zoho.books.getRecordsByID("contacts", "35201411","12340000000450123"); 
info response;

yields the following response format,

{
"message":"success",
"code":0,
"contact":{
"default_templates":{
"invoice_template_id":"",
"creditnote_email_template_id":"",
"creditnote_template_name":"",
"estimate_email_template_name":"",
"estimate_template_id":"",
"estimate_email_template_id":"",
"invoice_email_template_id":"",
"estimate_template_name":"",
"creditnote_template_id":"",
"invoice_template_name":"",
"invoice_email_template_name":"",
"creditnote_email_template_name":""
},
"payment_terms":0,
"payment_terms_label":"Due On Receipt",
"contact_id":"1782000000045001",
"price_precision":2,
"has_transaction":false,
"outstanding_receivable_amount_bcy":0,
"shipping_address":{
"zip":"",
"fax":"",
"address":"",
"state":"",
"country":"",
"city":""
},
"outstanding_receivable_amount":0,
"is_crm_customer":false,
"unused_credits_payable_amount":0,
"associated_with_square":false,
"company_name":"",
"contact_name":"Zoho Creator",
"currency_symbol":"Rs.",
"currency_code":"INR",
"cards":"[]",
"tags":"[]",
"custom_fields":"[]",
"currency_id":"1782000000000099",
"pricebook_id":"",
"status":"active",
"website":"",
"is_linked_with_zohocrm":false,
"payment_reminder_enabled":true,
"primary_contact_id":"",
"outstanding_payable_amount_bcy":0,
"bank_accounts":"[]",
"pricebook_name":"",
"source":"api",
"outstanding_payable_amount":0,
"unused_credits_receivable_amount":0,
"last_modified_time":"2015-02-18T15:01:39+0530",
"unused_credits_payable_amount_bcy":0,
"contact_persons":"[]",
"contact_salutation":"",
"contact_type":"none",
"created_time":"2015-02-18T15:01:39+0530",
"notes":"",
"billing_address":{
"zip":"",
"fax":"",
"address":"",
"state":"",
"country":"",
"city":""
},
"unused_credits_receivable_amount_bcy":0
}
}

If for some reason, the execution fails, the error response will be in the following format:

Error Response for - Wrong value for record id

{"message":"Contact does not exist.","code":1002}