Build a Dynamics 365 F&O connector
هذا المحتوى غير متوفر بلغتك بعد.
If your company runs Dynamics 365 Finance and Operations, the connector is an extension in your model: a few tables, a client class, and batch jobs. Most partners already have this skeleton from another integration — a parameters form, an HTTP client with retry rules, staging tables, an execution log. Pointing it at SLFLO changes the mappings and contracts, not the skeleton. This page lists each piece and what it does against SLFLO.
Read the pull connector and master data guides first: they show the same flow with code that runs.
The pieces
Section titled “The pieces”| Piece in your extension | Against SLFLO |
|---|---|
| Parameters table and form | Base URL https://api.slflo.com/api/integration/v1; the token, stored encrypted; page size (100); your throttle; the last version staged per stream and the last seq per document stream; an on/off switch per flow. |
API client class (a .NET HttpClient wrapper called from X++) |
Stop on 401 and alert (SLFLO never blocks an IP for 401s); wait Retry-After on 429; back off on 500, 502, 503, 504 and timeouts; send an Idempotency-Key on every POST/PUT/DELETE, retries included. See retries. |
| Throttle | Just under rate_limit_per_minute from GET /me (120 by default). |
| Data contracts | Generated or hand-written from openapi-v1.json: OrderDto, OrderLineDto, RefDto, TotalsDto, InvoiceDto, PaymentDto, ReturnDto, for van loads LoadPushDto, LoadResultDto, LoadDto, and for unloads UnloadPushDto, UnloadDto. Ignore fields you don’t know — new ones may be added to v1. |
| Staging tables | Header and lines, with a unique index on (SLFLO id, version, line number) and a status field. |
| Batch jobs (SysOperation) | One per flow — orders, invoices, payments, returns, master data — on a recurrence, each writing to your execution log with SLFLO’s request_id for every failed call. |
Orders → sales orders
Section titled “Orders → sales orders”- Pull
GET /orders?filter[status]=ERP_PENDING&filter[version_after]=<last staged version>&per_page=100, followingmeta.next_version_afteruntilhas_moreis false. Customer, branch, rep, product and unit come inline with both keys — no second call to look them up. - Stage every line under the unique index. A duplicate insert is not an error; skip it.
- Create one sales order per SLFLO order. Put the SLFLO order
idin the sales order’s customer reference (CustomersOrderReferenceon the sales order header entity) or in a field of your own, and search for it before creating. A job that died after creating finds its own sales order.- Customer account:
customer.external_ref. Delivery address:branch.external_ref, which readsACCOUNT/BRANCH. A shop the rep added on the phone hascustomer.external_ref: nulluntil you adopt it (see adopting a record); adopting it does not raise the order’sversion, so match a waiting order bycustomer.idtoo, or read it again withGET /orders/{id}. - Rep:
sales_rep.codeis the rep’s SLFLO code (EMP-017), set once and never changed — map it to your worker or sales group.sales_rep.external_refis empty in v1 (no rep push). - Warehouse: an order waiting for you has
"warehouse": null, because nothing has left a SLFLO van or warehouse yet. Take the warehouse from your own rule — the rep’s default warehouse, for example. See Which warehouse. - Lines:
product.external_refis your item number,unit.external_refyour unit symbol,quantity,unit_price,discount;is_free_goodslines at zero price. - Prices and VAT: the rep quoted the customer
unit_priceand the VAT intax[]. Fix the line price to it rather than letting trade agreements re-price, and map the taxcode(VAT) to your sales tax groups.
- Customer account:
- Ack
POST /orders/{id}/ack, ACCEPTED with the sales order number asexternal_ref, or REJECTED with areason_codeand the infolog text asmessage(the office reads it). Many at once:POST /ackswith"entity": "order".
A refused order the office fixes comes back at a higher version through the same pull; see the refusal path. An order you accepted never changes or gets cancelled in SLFLO afterwards; see what happens to an order after your answer.
Payments → customer payment journal
Section titled “Payments → customer payment journal”- Read
GET /payments?filter[seq_after]=<last receipt seq>— each receipt once, in issue order — or by version. - One journal line per payment: account type Customer, account
customer.external_ref, creditamount, datecollection_date. Mapmethod(CASH,CHEQUE,TRANSFER,INSTAPAY,WALLET, fromGET /reference/payment-methods) to your methods of payment; achequecarries bank, number and due date for post-dated cheques. - Settle against the debts in
allocations.kindisINVOICE—invoicenames it with both keys, itsexternal_refbeing what you acked the invoice with (empty until you have) — orOPENING_BALANCE, a balance the customer carried in from before SLFLO (invoiceisnull). A payment never allocates to a credit note; what it didn’t clear ison_account. - Ack with a key unique to the payment, such as
<journal>-<line>; the journal number or voucher, which several payments share, goes inexternal_number. See acks. - A payment reversed or a cheque bounced later is pending again (
filter[ack]=pending) with areversal(a chequeBOUNCEDorVOIDEDalways has one): reverse the journal and ack again.reversal.reversed_atis when the office recorded it in SLFLO. A cheque that only moves on — handed over, deposited, cleared — also makes the payment pending again; nothing changes in money, so ack it with the same keys. See invoices by seq. - A payment reversed before you booked it is still pending, now
REVERSED, until you answer it: answer REJECTED withreason_codeREVERSED_IN_SLFLO, and the office reads that it was reversed in SLFLO and needs nothing more. SLFLO’s balance already leaves it out, whatever you answer.
Returns → return orders or credit notes
Section titled “Returns → return orders or credit notes”- Read
GET /returns?filter[seq_after]=<last credit note seq>; a return gets itsseqwhen it is credited (credit_note_number). - Each line points at the original invoice line (
invoicewith both keys,invoice_line_number); mapreason(fromGET /reference/return-reasons) to your return reason codes, and create a return order (RMA) or a credit note as your process books returns. - A line of a lot-tracked product names its lot in
lot(the code, as on the invoice line’slots): put it in the return line’sInventBatchId.batch_idis SLFLO’s own id for it. - Each line says where its goods went in
held_back:false— back on the van for sale;true— into the van’s held-back place (VAN-03-Q), never sellable. Every expired line is held back, and so is a line the rep held back on a Did not sell or Wrong delivery return; a damaged line the inspector put back on the shelf is not. Arrive the goods where the line says, whatever the return’sreason. - Amounts:
line_totalis what the line credits — its share of what the invoice line was billed, after discount, VAT included — andtotalis their sum.unit_priceis the invoice line’s price before discount. A credit-note line posted with a sales tax group takesline_totalless its VAT, or the VAT is credited twice. locationis where the goods came back to: itscodeis the SLFLO van or warehouse code, as for an invoice’s warehouse.- SLFLO applies a credit note to the invoice it credits first, then to the oldest debt; that
application is not in v1, so settle your credit note against
invoicethe same way. - A credited return never changes. Ack it with your credit note’s id. SLFLO keeps it as the
return’s
external_ref(whatfilter[external_ref]and lookups find) and does not print it on its own credit note.
Invoices SLFLO issued
Section titled “Invoices SLFLO issued”SLFLO issues an invoice for what it delivers: every van sale, at the shop, and any order the
office delivers in SLFLO. If you don’t invoice those sales in Dynamics yourself, read GET /invoices?filter[seq_after]=… and book them — as your
accountant decides, for example as free text invoices — then ack with your voucher. The counter
has no gaps, so you can prove you hold every invoice.
- One invoice per delivery. An order delivered in two parts has two invoices, each with only
the lines that moved. A line’s
line_numberis the number of the order line it delivers, so match lines on it. - Line amounts.
discountis the whole line’s discount (this delivery’s share of the order line’s).line_totalis what the line is billed with VAT:quantity × unit_price − discount, plus the VAT intax[]unlessprices_include_tax. The net amount isline_totalless the line’s tax. A free-goods line hasunit_price0, VAT 0 andline_total0. - An invoice never changes, so your first ACCEPTED answer is final. If you refused one and later book it (the shop linked, the period opened), ack it ACCEPTED: SLFLO takes it.
Which warehouse
Section titled “Which warehouse”Every invoice says where its goods left from in warehouse: the rep’s van for a van sale
(VAN-03), the warehouse for a delivery the office recorded (MAIN). One invoice always
leaves from one place, so the lines carry no warehouse of their own. Post the invoice’s
inventory against that place:
- Map
warehouse.codeto yourInventLocationId— through a SLFLO reference field on your warehouse (for exampleSlfloWarehouseRef), or the same code when you name them alike.warehouse.external_refis your key when SLFLO knows it for that warehouse; vans have none. warehouseisnullonly when no stock moved in SLFLO — a company that keeps all its stock in Dynamics. Then fall back to the rep’s default warehouse, as you would without SLFLO.
Orders carry the same field once goods have left: a van sale’s order names its van, and an order the office delivered names the warehouse of its first delivery (an order delivered in parts from two places still names the first; each invoice names its own).
Which batch
Section titled “Which batch”For a product SLFLO tracks by lot, each invoice line lists the lots its goods came from in
lots, earliest expiry first — the van’s lots for a van sale, the warehouse’s for a delivery:
"lots": [ { "lot": "B-0925", "expires_on": "2026-10-20", "quantity": "4.000", "base_quantity": "4.000" }, { "lot": "B-1101", "expires_on": "2026-11-15", "quantity": "6.000", "base_quantity": "6.000" }]lotis the lot code: yourInventBatchId, the same code your load and unload journals send.quantityis in the line’s unit, three places; when the whole line came from lots, the lots add up to the line’squantity.base_quantityis the same amount in the product’s base unit — your inventory unit when you pushed it as the base unit.- One line can come from two lots, when the first ran out. Keep the sales line as billed and
give its inventory the lots: register each lot’s quantity against its batch when you pick or
post the line, or split the line into one line per lot with the lot’s
quantityif your process wants one batch per line. - A product SLFLO doesn’t track by lot has
"lots": [], and so does every line when no stock moved in SLFLO (warehouseisnull). Then let Dynamics pick the batch as it would without SLFLO. - Two lines of one product (the paid line and its free goods) share the lots in line order.
Check which products SLFLO tracks by lot with GET /lookup?entity=product&external_ref=<ItemId>:
product.tracking is BATCH, NONE or SERIAL. Compare it with your item’s tracking dimension
group before the first load, so both sides agree on which lines carry a batch.
Load journals
Section titled “Load journals”When the company’s stock is managed in Dynamics (Stock is managed in your ERP, GET /me →
company.stock_managed_by_erp), every van load is a transfer journal from a warehouse to the
van’s warehouse. Stock from your ERP has the calls;
in the extension:
| Dynamics 365 | Against SLFLO |
|---|---|
| Transfer journal saved, Send to SLFLO | PUT /stock/loads/{JournalId} with van and from as SLFLO location codes (the warehouse’s SLFLO reference, else its InventLocationId), the journal number as number, each line’s item, unit, quantity and batch. Store the answer’s id and LD- number on your queue row. |
| Journal edited while the load waits | The same PUT with a new Idempotency-Key: replaced (a new load id) or updated |
| Journal deleted | DELETE /stock/loads/{JournalId} |
| Answers | GET /stock/loads?filter[version_after]=… each run. Act on a row only when its id is the journal’s current SLFLO load id. ACCEPTED → post the journal; REFUSED → show refusal.reason and refusal.note on the journal and alert the storekeeper. |
| Refused journal fixed | The same PUT again with a new key: a re-send, a new load id |
409 LOAD_ALREADY_CHECKED on an edit or delete |
The rep already accepted: don’t post the edited journal; mark it failed and alert |
| Waiting too long | GET /stock/loads/{JournalId} re-checks it |
| New van | GET /lookup?entity=van&external_ref=<code> before the first load: exists, and van.rep to compare with your rep mapping |
Post the journal only on ACCEPTED. SLFLO already put the goods on its van when the load
arrived and took them back if the rep refused, so there is nothing to tell SLFLO after posting.
Unload journals
Section titled “Unload journals”The storekeeper counts the van in Dynamics and posts a transfer journal back to the warehouse,
and the held-back goods in their own journal from the van’s quarantine warehouse (VAN-03-Q) to
the warehouse’s (WH-MAIN-Q). Stock from your ERP
has the call; in the extension:
| Dynamics 365 | Against SLFLO |
|---|---|
| Unload journal posted | PUT /stock/unloads/{JournalId} once, with van, to (SLFLO location codes), held_back: true for the quarantine journal, counted_at = the posting time, the journal number as number, and each counted line’s item, unit, quantity and batch. Store the answer’s id and UL- number. |
409 LOAD_STILL_WAITING or VAN_DAY_NOT_ENDED (retryable: true) |
Keep the journal queued and send it again on a later run, with the same body. A load still waits on the van, or the rep hasn’t ended the day. |
409 UNLOAD_ALREADY_RECORDED |
The journal was edited after SLFLO recorded it: mark the queue row failed and alert; a correction is a new journal. |
shortages in the answer |
The rep’s shortage, written off SLFLO’s van. It stays on the Dynamics van until your accountant clears it, so Dynamics van = SLFLO van + its uncleared shortages. |
| Re-check | GET /stock/unloads/{JournalId} |
Send only posted journals: a posted journal isn’t deleted, and SLFLO records each ref once.
Master data out
Section titled “Master data out”| SLFLO | From Dynamics 365 | Call |
|---|---|---|
| Customer | Customer account (AccountNum), name, credit limit, blocked, customer price group |
PUT /customers/{AccountNum} |
| Branch | The customer’s delivery addresses | PUT /customers/{AccountNum}/branches/{ref} |
| Unit | Unit symbol | PUT /units/{Symbol} or POST /batch/units |
| Product | Item number, name, inventory unit, active | PUT /products/{ItemId} or POST /batch/products |
| Sellable units | Unit conversions to the inventory unit | PUT /products/{ItemId}/units |
| Price list | Customer price group | PUT /price-lists/{PriceGroup} |
| Prices | Sales trade agreements for the group, resolved to one price per item, unit and from-date | PUT /price-lists/{PriceGroup}/prices (≤ 500 rows, several merge calls when more) |
| Balance | The customer’s open balance, and when it was taken | PUT /customers/{AccountNum}/balance or POST /batch/balances |
There is no id to store: you push by your own keys. Keep a hash of each payload you sent
(MD5 or SHA-256 of the JSON) in a small table and skip the call when it hasn’t changed; SLFLO
answers unchanged anyway, but skipping saves the request. Send the record’s modified time as
source_version so two jobs racing can’t roll a record back.
Mapping tables
Section titled “Mapping tables”Fetch SLFLO’s code lists once and map them in small tables of your own:
GET /reference/payment-methods, return-reasons, units, warehouses, tax-codes. Each item
has code, a name in English and Arabic, and — for the company’s own lists — your key beside ours.
The order of work
Section titled “The order of work”- Parameters: the base URL and a sandbox token (
sfi_live_…); check it withGET /me. - Map the code lists.
- Master data out: units, price groups, items, prices, customers, balances — by your keys, with the payload-hash skip.
- Documents in: orders, then payments, returns and invoices — pull, stage, create with find-before-create, ack.
- When the company’s stock is kept in Dynamics: load journals out and their answers back, then posted unload journals (stock from your ERP, its worked example Karim’s day). In the batch, read the load answers before you post the day’s invoices, and send unloads after them.
- Run the go-live checklist against the sandbox (the stock sandbox for step 9), then switch the parameters to a live token.

