Salesforce and Israeli Invoicing: Issuing a Tax Invoice When an Opportunity Closes
Back to blog
automation·September 30, 2026·6 min read·By Yehonatan Saadia

Salesforce and Israeli Invoicing: Issuing a Tax Invoice When an Opportunity Closes

How to connect Salesforce to Morning, iCount, Invoice4U or Priority so a won Opportunity issues a tax invoice: the Flow, Apex and middleware options, the API limits per edition, and where the allocation number is written back.

Key takeaways

  • Trigger on the Opportunity's IsWon field, which Salesforce sets from StageName, not on a stage label.
  • Call the invoicing API after the save is committed: a Run Asynchronously Flow path or a Queueable Apex job.
  • A Flow HTTP Callout only faults on status 300 or higher, so Invoice4U errors returned with 200 need an explicit check.
  • The invoicing system obtains the allocation number; Salesforce stores it next to the document number and a status field.

To issue an Israeli tax invoice when a Salesforce Opportunity closes, you trigger on the Opportunity becoming won, call the invoicing system's API (Morning, iCount, Invoice4U or Priority) outside the save transaction, and write the document number, document id and allocation number back to the Opportunity. Salesforce never obtains the allocation number itself - the invoicing system does.

Salesforce is a common CRM in Israeli B2B companies, and it has no native connection to Israeli invoicing systems. So the sales team closes a deal in Salesforce and someone retypes it into the invoicing system. This guide covers the integration options Salesforce actually offers, the order of operations that avoids duplicate tax documents, and what changes per invoicing system. If you are still choosing a CRM, the comparison is in HubSpot vs Salesforce.

What should trigger the invoice in Salesforce?

The trigger should be the Opportunity's IsWon field turning true, not a specific stage label. According to Salesforce's object reference, IsWon and IsClosed are booleans controlled by StageName: you can filter on them, but you cannot set them directly. A condition on IsWon keeps working when an admin renames the "Closed Won" stage or adds a second won stage.

Two more fields matter before any amount leaves Salesforce. AccountId points to the customer, where the ח"פ or ת"ז usually lives in a custom field. And Amount, on an Opportunity with products, is the sum of its line items - an update that tries to change it is ignored, not rejected. The invoice lines should therefore come from the Opportunity's products, not from a single total.

Which Salesforce integration option should you use?

The right Salesforce option depends on where the retry logic and the credentials should live. Salesforce offers four realistic routes to call an Israeli invoicing API:

OptionHow it runsFits whenWatch out for
Record-triggered Flow with HTTP CalloutA "Run Asynchronously" path runs after the Opportunity save is committed and calls the API through a Named CredentialOne document per deal, simple JSON, an admin maintains itRequest headers are not supported in the action; only status 300 or higher reaches the fault path
Apex (Queueable) calloutCode calls callout:Your_Named_Credential/... and handles the responseLine-item mapping, custom error parsing, multiple documentsMax 100 callouts per transaction, 120 seconds cumulative timeout, no callout after pending DML
Middleware subscribed to Change Data CaptureAn external service receives Opportunity change events and calls the invoicing APIThe invoicing logic already lives outside SalesforceChange Data Capture is available in Enterprise, Performance, Unlimited and Developer editions only
Middleware polling the REST APIA scheduled job queries newly won OpportunitiesLow volume, or an edition without Change Data CaptureEvery query and write-back counts toward the daily API allocation

The Flow route is the lightest. Salesforce's release note for the asynchronous path describes it as the way to call an external service after the triggering record is committed, and notes that the path can be delayed when system resources are unavailable - acceptable for an invoice, which should not sit in the user's save anyway. Apex gives full control, with the limits in the table taken from Salesforce's callout documentation: a default timeout of 10 seconds per callout, configurable up to 120,000 milliseconds.

The order of operations, step by step

  1. Detect the win. A record-triggered Flow (after save, "Is Changed" on IsWon) or a Change Data Capture subscriber notices the Opportunity closing as won.
  2. Mark it pending. Set a custom status field, for example Invoice_Status__c = Pending, so a second trigger does not start a second document.
  3. Build the document from the Account (name, ח"פ, email) and the Opportunity products (name, quantity, price), with VAT handling decided per product.
  4. Call the invoicing API outside the save transaction, sending the Opportunity id as your own unique reference.
  5. Read the result, not only the status code. Parse the response body for errors before treating the call as a success.
  6. Write back the document number, the document id and the allocation number to fields on the Opportunity, and set the status to Issued or Failed with the error text.

If the write-back comes from middleware, it is a PATCH to the REST API's sObject Rows resource for that Opportunity (/sobjects/Opportunity/{id}), and it counts toward the org's inbound API allocation.

Where does the allocation number fit?

This section is a technical description, not tax advice. Under the Israel Invoices model, a tax invoice that meets the statutory conditions carries an allocation number (מספר הקצאה) issued by the Tax Authority. In a Salesforce integration the invoicing system requests that number as part of issuing the document; Salesforce's job is to store what comes back and to notice when it did not come back.

Invoice4U, for example, returns AllocationNumber and AllocationMessage on the document, and FetchAllocationNumber requests one for an existing document. Which invoices need a number is set by the Tax Authority and has changed during 2026, so the rule belongs in configuration, never in a Flow condition or an Apex constant. The engineering side, including what to do when the Tax Authority service is slow, is covered in the allocation number API guide. Which documents your business must issue is a question for your accountant.

What changes with each Israeli invoicing system?

The Salesforce side stays the same; the invoicing side differs in authentication and in how errors come back:

  • Invoice4U reports business errors inside a 200 response, in a d.Errors array. A Flow HTTP Callout treats only status 300 and above as an error, so without an explicit decision on Errors a failed call looks successful. CreateDocumentWithIdentifierValidation with ApiIdentifier set to the Opportunity id rejects a retry instead of issuing a second document. Details in the Invoice4U API guide.
  • iCount's current v3 API takes a token in the Authorization header. Since the Flow action does not accept request headers, that header has to be defined on the Named Credential.
  • Morning (Green Invoice) issues short-lived tokens from long-lived API credentials, which must be cached and refreshed. If that exchange does not fit a Named Credential's authentication options, the refresh moves into Apex or middleware. See automating Morning through its API.
  • Priority is usually the ERP rather than a standalone invoicing tool, reached over its REST/OData interface, and every installation is customised. A won Opportunity typically becomes an order or invoice in Priority, and the field list comes from the client's own sandbox.

What goes wrong in a Salesforce to invoicing integration

  • Duplicate invoices from retries. A timeout does not mean nothing was issued. Always send the Opportunity id as the external reference and check for an existing document before retrying.
  • A reopened Opportunity. If a won deal is moved back and won again, the trigger fires twice. The pending or issued status field is what stops the second document.
  • Callout after DML. Apex cannot make a callout while DML is pending in the same transaction, which is why the call belongs in a Queueable job or an asynchronous Flow path.
  • Hitting the API allocation. Salesforce's allocations are counted for the whole org over 24 hours, not per user: 15,000 calls in Developer Edition, and 100,000 plus per-license calls in Enterprise Edition. Monitor them with the /limits resource or the Sforce-Limit-Info response header.

Professional Edition appears in Salesforce's allocation table only "with API access enabled", so confirm API access on the client's edition before planning any middleware route.

Sources

#Salesforce#Salesforce integration#Invoice4U#Morning#allocation number#invoicing API

Frequently asked questions

Can Salesforce issue an Israeli tax invoice on its own?

Not natively. Salesforce has no built-in connection to Morning, iCount, Invoice4U or Priority, and it does not request allocation numbers from the Tax Authority. The usual design lets the invoicing system issue the document, triggered by a won Opportunity, and writes the document number and allocation number back to Salesforce.

Can I connect Salesforce to an invoicing API without code?

Often, yes. A record-triggered Flow with a Run Asynchronously path and an HTTP Callout action can call a JSON API through a Named Credential. The limits are real: the action does not accept request headers, and only a response status of 300 or higher reaches the fault path, so errors returned with status 200 need an explicit check.

Which Salesforce field should trigger the invoice?

IsWon on the Opportunity. Salesforce sets it from StageName and does not let you set it directly, so a condition on IsWon survives renamed or added won stages. Combine it with a custom invoice status field, so a deal that is reopened and won again does not produce a second tax document.

Does the integration use up my Salesforce API calls?

Inbound calls do. Salesforce counts REST, SOAP and Bulk API requests into the org over a rolling 24 hours, for the whole org rather than per user. Enterprise Edition starts at 100,000 plus per-license calls. A middleware that polls for won deals and writes results back spends calls on both; check usage at the /limits resource.

Where should the allocation number be stored in Salesforce?

On the Opportunity, in a custom field next to the invoice number and the invoicing system's document id, with a status and an error field beside them. The number comes from the invoicing system's response. If it is missing, the Opportunity should show that, rather than looking invoiced when the document is incomplete.

Keep reading

Related service

Integrations

Make the systems you already pay for talk to each other.

Learn more →←

About the author

Yehonatan Saadia

Freelance automation, web & MVP developer

I'm Yehonatan Saadia, a senior developer who builds business automation, custom websites, and MVPs for small and mid-sized companies across the US, Europe, and Israel. These guides come from real client work, not theory.

Work with me

Have a project like this?

Tell me what you're trying to automate or build. I reply within 24 business hours with a few targeted questions, then we walk through it on a free 30-minute call, with no commitment. You come away with a scope, a timeline and a fixed price - or a straight answer that it isn't worth building.