Querying Sales Orders from ERP: A Practical Sync Strategy for Shipped Orders
What This Strategy Solves
In cross-border retail or distribution, sales orders live in multiple systems: CRMs for deal-making and order entry, ERPs for review, fulfillment, and shipping. Post-sales and finance teams need a unified view—especially of orders that have already shipped, since those orders immediately affect inventory and revenue. This strategy addresses one specific need: pulling shipped sales orders from the cross-border ERP back into the integration platform on a schedule, using the ship-time window, so that downstream sync, reporting, and reconciliation jobs have a reliable data source. It is a textbook implementation of the incremental track in the "incremental + full" dual-track pattern.
Data Flow and Field Mapping
The flow is one-directional: Source (cross-border ERP) → Qeasy Data Integration Platform → Target (internal landing in the platform). Note that the "target" here is not an external business system but an internal WebAPI write, designed to persist the query result into the middle layer for downstream strategies.
Key field mapping:
| Business meaning | Source field | Target field | Notes |
|---|---|---|---|
| Order status | status | Pass-through | Multi-value, e.g. 1,3,4 |
| Ship time start | expressTimeStart | Expression | `{{LAST_SYNC_TIME |
| Ship time end | expressTimeEnd | Expression | `{{CURRENT_TIME |
| Order IDs | platformOrderIds | Pass-through | Single or batch; overrides time window |
| Pagination | page | Pass-through | Defaults to 1; loop for large volumes |
One design detail: idCheck=false and buildModel=false. This pull does not deduplicate or build a canonical model. It writes raw results into the middle layer and leaves cleaning and mapping to downstream strategies.
How to Configure on Qeasy
We use the Qeasy Data Integration Platform to run this pull. Four configuration points matter:
- Combine QUERY + EXECUTE: the source side is a query API (POST), the target side is an internal WebAPI write. This combination is common in Qeasy; engineers can think of it as "fetch + land".
- Use platform variables for the time window: never hard-code times. Use the built-in
LAST_SYNC_TIMEandCURRENT_TIMEvariables. On the very first run, set an initial value manually—the platform then remembers the watermark. - Multi-value status field:
statusaccepts a comma-separated string such as1,3,4. Configure it as a multi-select string in the request parameters; the platform passes it through as-is to the ERP. - Request body template: the ERP usually expects
application/x-www-form-urlencodedor JSON. Pick the encoding in the request parameters based on what the source system actually accepts.
Implementation Steps
We break the rollout into three phases, matching the common customer pattern of "incremental anchor / full backfill / steady-state schedule":
- Step 1, fix the incremental anchor. Before the first run, manually identify the earliest ship time that should be pulled, and set it as the initial value of
LAST_SYNC_TIME. This is the anchor for all future increments. A wrong anchor means data is either missed or duplicated later. - Step 2, trigger a one-time full backfill. Widen the time window (e.g., the last 30 days) and trigger a manual run. Use it to verify that the response structure, field names, and pagination match the documentation. This step runs only once and exists to expose problems early.
- Step 3, move to steady-state scheduling. Set a cron based on order volume. The source material uses
3 2,14 * * *, i.e., 02:03 and 14:03 every day. If volumes are large and shipping peaks cluster, shifting the afternoon run to 16:00 avoids the ERP's busiest hours and noticeably reduces timeouts.
Lessons Learned
On a real project, we hit several pitfalls on this deceptively simple strategy. They are worth recording:
- Watermark rollback causes duplicates. If the source allows editing the ship time (address changes, return reships), an already-pulled order can re-enter the window and be fetched again. The safe move is to enable idempotent deduplication on
platformOrderIdon the target side; in Qeasy, just check the primary key on the write strategy. - Unhandled pagination drops data. The default behavior pulls only page 1. Without an explicit loop, half the orders vanish on busy days. A typical mistake is to validate only with a few dozen test orders. The safe approach is to loop pages of 100 until the response is empty.
- Timezone confusion.
LAST_SYNC_TIMEuses the platform's timezone by default. If the ERP runs in UTC, windows shift and data is either missed or duplicated. Declare both timezones explicitly in the configuration; do not rely on defaults. - Status code drift across versions. "Shipped" may map to different status values across ERP versions.
1,3,4is a common combination, but never copy it blindly when upgrading or switching APIs—re-verify.
When It Fits and When It Doesn't
Fits: cross-border retail and distribution scenarios that need an incremental, time-window-based pull of shipped orders into a middle layer for reconciliation, BI, or inventory writes. Does not fit: business that requires real-time, per-event push with strict latency budgets (use event-driven instead), or workloads where a single window exceeds 100k orders and needs parallel splitting—those exceed this strategy's design assumptions.