Automate Salesforce 'Closed-Won' Leads to Xero Invoices (Zapier)

Eliminate manual data entry and accelerate the Lead-to-Cash cycle using Zapier's multi-step logic.

Tools: SalesforceXero

Platform: Zapier

Short Answer

Every time an Opportunity is marked 'Closed-Won' in Salesforce, Zapier automatically syncs the customer data to Xero and generates a professional Draft Invoice with corresponding line items, ensuring financial accuracy and faster payments.

The Problem

Sales teams often experience a manual bottleneck when a deal is closed. Manually copying Salesforce Opportunity data into Xero for invoicing leads to data entry errors, delayed billing, and a lack of visibility for sales reps regarding payment status.

The Outcome

Every time an Opportunity is marked 'Closed-Won' in Salesforce, Zapier automatically syncs the customer data to Xero and generates a professional Draft Invoice with corresponding line items, ensuring financial accuracy and faster payments.

Step-by-Step Guide

1. **Authenticate Salesforce**: Create a new Zap and choose **Salesforce** as the Trigger. Select **Updated Field in Record**. Connect your Salesforce account and select 'Opportunity' as the Object and 'Stage' as the Field. 2. **Set Logic Filter**: Add a **Filter by Zapier** step. Configure it to only continue if the `Stage` field 'Exactly matches' `Closed-Won`. This prevents the Zap from consuming tasks on early-stage deals. 3. **Format Line Items**: If your Opportunity has multiple products, add **Formatter by Zapier > Utilities > Line Itemizer**. Map the Salesforce Opportunity Line Item Names, Quantities, and Prices. This ensures Xero receives an array rather than a single string. 4. **Sync Customer to Xero**: Add a **Xero** action step: **Find or Create Contact**. Search by the Salesforce 'Account Name'. Check the box 'Create Xero Contact if it doesn't exist yet' and map the Billing Address and Email from Salesforce. 5. **Generate Invoice**: Add a **Xero** action step: **Create Sales Invoice**. - Select the Contact ID from the previous step. - Set 'Status' to 'Draft' (safest for finance review). - Map the Line Itemizer output to the 'Line Items' section. - Map the Salesforce 'Opportunity ID' to the Xero 'Reference' field to prevent duplicates. 6. **Duplicate Prevention**: Before the Invoice step, you can optionally add a **Xero: Find Invoice** step using the Salesforce Opportunity ID. Use a Filter to only proceed if an invoice is *not* found. 7. **Close the Loop**: Add a final **Salesforce: Update Opportunity** action. Pass the 'Invoice ID' or 'Xero URL' back to a custom field in Salesforce so the Sales Rep can see the invoice was created. 8. **Turn on Error Handling**: Click the down arrow on the Xero step and select **'Add extra step' > 'Always hide/skip'** or use **Zapier Manager** to catch errors and send a Slack/Email alert if the invoice fails due to tax mapping issues.