Automated Salesforce Opportunity to Xero Multi-Line Invoicing (Make.com)

Streamline Lead-to-Cash by synchronizing Salesforce Closed-Won Opportunities with Xero Invoices using Make.com's advanced line-item processing.

Tools: SalesforceXero

Platform: Make.com

Short Answer

A fully automated workflow that triggers upon a 'Closed-Won' status in Salesforce, pulls all associated line items, searches for or creates the Xero Contact, and generates a detailed Draft Invoice ready for review.

The Problem

Manual entry of Salesforce Opportunity data into Xero causes billing delays, human error in line-item pricing, and data silos between Sales and Finance teams. Standard integrations often struggle to map multiple products from a single deal into a structured accounting format.

The Outcome

A fully automated workflow that triggers upon a 'Closed-Won' status in Salesforce, pulls all associated line items, searches for or creates the Xero Contact, and generates a detailed Draft Invoice ready for review.

Step-by-Step Guide

1. **Create the Scenario**: Log into Make.com, click 'Create a new scenario', and name it 'Salesforce to Xero: Opportunity Invoicing'. 2. **Salesforce Trigger**: Add the 'Salesforce > Watch Records' module. Set the 'Object' to 'Opportunity'. Use a filter in the module settings or a Make filter to only process records where 'Stage Name' = 'Closed Won'. 3. **Identify/Create Contact**: Add a 'Xero > Search for Contact' module. Map the Salesforce 'Account Name' to the Xero 'Name'. Add a Router: if no contact is found ($body.length = 0), use the 'Xero > Create a Contact' module; otherwise, proceed to the next step. 4. **Get Line Items**: Add a 'Salesforce > List Opportunity Products' module. Pass the 'Opportunity ID' from the trigger to fetch all associated SKUs, quantities, and prices. 5. **Process Line Items (Iterator)**: Add an 'Iterator' module. Map the 'Array' of products from the previous Salesforce step. This breaks the product list into individual bundles. 6. **Build the Xero Array (Aggregator)**: Add an 'Array Aggregator' module after the Iterator. Set the 'Source Module' as the Iterator and the 'Target Structure' as the 'Line Items' field for a Xero Invoice. Map Product Code, Quantity, and Unit Price. 7. **Generate Invoice**: Add the 'Xero > Create an Invoice' module. Map the 'Contact ID' from Step 3 and the 'Line Items' array from Step 6. Set 'Status' to 'DRAFT' to allow for final Finance approval. 8. **Add Error Handling**: Right-click the Xero module and select 'Add error handler'. Use a 'Break' or 'Rollback' directive to ensure that failed invoice creations are logged and the operation is retried or paused to prevent duplicate data.

Data Mapping

| Salesforce Field | Xero Field | Transformation/Function | Requirement | | :--- | :--- | :--- | :--- | | Account.Name | Contact Name | `trim(Account Name)` | Required | | Opp.CloseDate | Date | `formatDate(CloseDate; YYYY-MM-DD)` | Required | | Opp.CloseDate + 30 | Due Date | `addDays(CloseDate; 30)` | Optional | | LineItem.ProductCode | ItemCode | `ifempty(Code; "GENERIC")` | Required | | LineItem.Quantity | Quantity | `parseNumber(Quantity)` | Required | | LineItem.UnitPrice | UnitAmount | `parseNumber(UnitPrice)` | Required | | Opp.Name | Reference | `Opportunity ID + " - " + Name` | Optional |

Gotchas & Failure Modes

* **Line Item Limits**: Xero API may timeout if an Opportunity has 500+ line items; use Make's 'Sleep' module if processing massive batches. * **Currency Mismatch**: Ensure the 'Currency Code' in Salesforce matches the established Currencies in Xero settings, or the module will return a 400 error. * **Rate Limits**: Salesforce API limits (calls per 24h) can be consumed quickly; use 'Watch Outbound Messages' (Webhooks) instead of polling if you have high volume. * **Rounding Errors**: Make sure to use `formatNumber(value; 2; "."; "")` for currency fields to prevent Xero from rejecting values with more than two decimal places.

Verification Checklist

- [ ] Run the Salesforce module individually using 'Choose where to start' to pull a specific Closed-Won Opportunity ID. - [ ] Use the 'Run this module only' feature on the Xero Search step to ensure Contact mapping is accurate. - [ ] Check the 'Execution Inspector' (the bubble above the modules) to verify the Line Item array is correctly structured before it hits the Xero Invoice module. - [ ] Switch to Xero 'Demo Company' environment for initial testing to avoid polluting live financial books. - [ ] Verify that the 'Total Amount' in the Xero Draft matches the Salesforce Opportunity 'Amount' exactly.

Ready to Automate?

Build this automation with Make.com in minutes.