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.
- Bank Accounts
<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.
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,
- Select the Form from your Dashboard page.
- Click on Settings - On Add - Actions on Success.
- 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\"");
- 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)
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:
To add the script using the drag-n-drop functionality in Script Builder,
- Select the Form from your Dashboard page
- Click on Settings - On Add - Actions on Success
- Click on Script Builder from the top-right corner of the page.
- Drag and drop the call function in the editor box.
- Select Integration tasks.
- Select Service as Xero.
- Select Function as Get Records.
- 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.
- Select the required Module name in Xero.
- Select the Query based on which the records will be fetched.
- Specify the response variable that will hold the response returned by Xero.
- 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.