Overview of Integration
Integration of Xero (used for accounting) and Salesforce CRM is required to automate several tasks. Simplification of creating and viewing Xero Customers and Invoices can be achieved by integrating the aforementioned apps. Even if the pre-built Salesforce Integration for Xero may not suffice for your company’s needs, a custom Apex can be created and a solution developed. Instruction on achieving this will be provided in this post! Combining the two platforms requires admin access to Salesforce (Enterprise Edition or higher, or a Dev/Sandbox org for testing) and Xero. Additionally, prior knowledge of Apex coding is necessary. If Apex utilization is unfamiliar, consideration might be given to employing Zapier’s no-code integration or Breadwinner’s no-code interface with Salesforce.
Remote Site Settings
Registering the target site in the Remote Site Settings is necessary for a callout from Salesforce to an external website. Salesforce restricts calls to unregistered network addresses. If the site is not registered, the callout will not function. Before calling Xero Endpoints, two remote site configurations must be created in Salesforce using below mentioned steps:
- Go to Setup.
- Type “Remote Site” into the Quick Find search bar.
- Then select “Remote Site Settings.”
- Make the following two remote site configurations, each with a distinct function.
- Use this URL to authenticate yourself and get the access token: https://identity.xero.com/
- Use this URL to carry out operations on data, including contacts, invoices, bills, and purchase orders:
Xero Contacts
Reading Contacts
To get the details of your Xero Contact(s), use the code below. You may also use the “IDs” option in the endpoint to retrieve specific Xero Contact information.
Managing Xero Contacts – Creation and Update
Adhering to Xero API guidelines necessitates completing certain mandatory fields when creating a Xero Contact. Moreover, when upgrading a Xero Contact, it’s crucial to incorporate the “ContactID” in the request body. The provided code can be employed to create or update a Xero contact based on the value of the “isCreate” option. If the “isCreate” argument is TRUE, the request method will be specified as PUT; otherwise, it will be configured as POST.
Xero Invoices
Reading Invoices
To get the details of a Xero invoice(s) from Xero, use the code that is provided below. You may also use the “IDs” option in the endpoint to retrieve specific Xero Invoice data.
Managing Xero Invoices – Creation and Update
In accordance with Xero API guidelines, a few required fields must be filled out when generating a Xero invoice. However, it is essential to include the “InvoiceID” in the request body when changing a Xero invoice. Depending on the value of the “isCreate” option, the code below can be used to create or update a Xero invoice. The request method will be specified as PUT if the “isCreate” argument is set to TRUE; otherwise, it will be configured as POST.
Alternatives to a Custom Integration
Breadwinner’s Xero Salesforce Integration is an alternative option, if there are challenges in developing a customized Apex integration. It may be due to limitations such as the absence of LWC components or difficulties in managing updates and race conditions. This solution can aid in the rapid expansion and scaling of your organization, with clear and defined costs. Alternatively, integration of Salesforce and Xero can be achieved using Workato or Zapier.