Get Records from Xero

Table of Contents


The xero.getRecords() task is used to fetch records from any of the supported modules of your Xero account, to your Zoho Creator Application. For example, you can fetch records from Xero modules like Contacts, Accounts, Items etc. To connect Zoho Creator with Xero, add a new connection from the Setup - Connections page.

Supported Modules

  • Contacts
  • Accounts
  • Items
  • Bank Accounts
  • Invoices
  • Employees


getresponse= xero.create("xeroConnectioName", "xeroModuleName", query);

<getresponse> is the map variable returned as response. It contains the details of the newly created record.
<xeroConnectioName> refers to the connection name used to connect Zoho Creator with Xero. Create a new connection from the Setup - Connections page.
<xeroModuleName> refers to the module name in Xero where the record is created.
<query> refers to the label name and its value based on which records will be fetched.

Example - To fetch records

A sample script to fetch a record from the Xero Contacts module is given below. You can execute this script from a Zoho Creator form by adding it to the required Form Actions block. For example, to fetch a record from the Contacts module,

  1. Select the Form from your Dashboard page.
  2. Click on Settings - On Add - Actions on Success.
  3. Add the following script to the editor area and click on Save Script to save the script definition.

    //fetching the record with ContactId = "4f80a131-3943-4dc3-9dd6-032d727ccdad" from Xero Contacts module
    getresponse = xero.getRecords("Xero", "contacts", "ContactID = Guid(\"4f80a131-3943-4dc3-9dd6-032d727ccdad\")");


    //You can also fetch records based on multiple queries
    getresponse = xero.getRecords("Xero", "contacts", "FirstName=\"John\" && LastName=\"Smith\"");

  4. Upon submitting the form, the details of the record with ContactId = "4f80a131-3943-4dc3-9dd6-032d727ccdad" are fetched. In case of multiple queries example, records containing First Name = "John" and Last Name = "Smith" are fetched.


  • If no queries are specified all the records are fetched.
  • You can add the script directly to the editor area by selecting Free-flow scripting link displayed on the top-right corner of the script builder ( or ) use the drag-and-drop functionality in Script Builder.
  • In the above example, we have specified the param values directly within quotes. To fetch the param values from a Zoho Creator form, specify the field deluge name used in the form. For example, if First_Name is the Field Deluge name, the key value pair should be specified in the following format: ("FirstName", First_Name)

Response Format

The response returned by Xero will be in the format given below:

"ProviderName":"Zoho Creator Local",

"Name":"John Taylor Smith",


If the execution fails due to incorrect parameter value,the response will be in the following format:

{"Message":"Operator '=' incompatible with operand types 'Guid' and 'String'","Type":"QueryParseException","ErrorNumber":16}

Using Script Builder

To add the script using the drag-n-drop functionality in Script Builder,

  1. Select the Form from your Dashboard page
  2. Click on Settings - On Add - Actions on Success
  3. Click on Script Builder from the top-right corner of the page.
  4. Drag and drop the call function in the editor box.
  5. Select Integration tasks.
  6. Select Service as Xero.
  7. Select Function as Get Records.
  8. Select the Connection Name to connect with Xero. Click on +Create to create a new connection or create a new connection from the Setup - Connections page.
  9. Select the required Module name in Xero.
  10. Select the Query based on which the records will be fetched.
  11. Specify the response variable that will hold the response returned by Xero.
  12. Click on Done to insert the call function task.

Upon submission of the form, the records get fetched based on the specified query. The response variable will contain the response returned by Xero.

Share this post : FacebookTwitter