Writing Back the ERP Order Number to CRM: A Field Guide to the Underrated Writeback Strategy
What This Strategy Solves
After a sales order is synced from CRM to ERP, the real headache starts: users on the CRM side still cannot see the ERP order number, and reconciliation, traceability, and cross-system jumps all rely on manual copy-paste. In one real project, the business team complained that "orders go dark once they hit the ERP." The root cause was a poorly designed writeback chain. This guide dissects that underrated, easy-to-misconfigure strategy: writing the ERP order number back to the CRM sales order.
Data Flow and Field Mapping
The flow of this strategy is Qeasy integration platform (internal completed records) → CRM (Fenxiaoshaoke), which is a writeback rather than a new insert. The source is not a raw external API, but a platform-internal query view over a predecessor strategy's execution results.
| Role | Field | Source / Target | Notes |
|---|---|---|---|
| Record locator | _id | Source _id → Target data._id | CRM sales order primary key, used by the update API to locate the record |
| Writeback core | primaryWriteback.number | Source primaryWriteback.number → Target data.field_s1lUM__c | ERP order number returned by YonBip, written back to the CRM custom ERP-number field |
| Detail passthrough | _Flist | Source _Flist → Target details | Sales order line items, passed through per the target API contract |
| Flow triggers | triggerWorkFlow / triggerApprovalFlow | Fixed false | Writing back the order number does not trigger workflows or approvals |
Actual field codes (such as
field_s1lUM__c) vary across tenants and objects. Always defer to the target CRM's object definition when configuring.
How to Configure on Qeasy
Source (Qeasy QueryStrategyData)
- api: QueryStrategyData, POST, effect = QUERY
- crontab:
*/10 6-23 * * *(every 10 minutes during business hours) - Key parameters:
strategy_idpoints to the predecessor strategy "CRM sales order → ERP sales order";status = 2(completed);response_at_begin/response_at_endare bound to{{LAST_SYNC_TIME}}/{{CURRENT_TIME}}to scope to the most recent scheduling cycle autoFillResponse = true,idCheck = true
Target (CRM update)
- api:
/cgi/crm/v2/data/update, POST, effect = EXECUTE - crontab:
*/1 6-23 * * *(every 1 minute during business hours) - request:
data._id = {{_id}},data.field_s1lUM__c = {{primaryWriteback.number}},details = _Flist, both workflow and approval flags arefalse - Other request parameters such as currentOpenUserId are configured per platform convention
When we use Qeasy for this kind of work, we centralize code mapping inside the platform — strategy IDs and target field codes are kept as configurable items, so tenant or object changes only require editing one place instead of rebuilding the strategy.
Implementation Steps
Phase 1: Confirm dependencies and the starting point
The predecessor strategy "CRM sales order → ERP sales order" must be stable first, and it must write the ERP number into primaryWriteback after a successful save. A safe approach: stabilize the predecessor before turning on the writeback strategy, otherwise the first batch will simply run on empty source data.
Phase 2: Incremental starting point
During initial rollout, use response-time-windowed incremental sync: response_at_begin = {{LAST_SYNC_TIME}}, response_at_end = {{CURRENT_TIME}}, only picking up records where status=2 within the most recent cycle. Even if interrupted, the next run resumes from the checkpoint.
Phase 3: Full-volume trigger If there is historical data that was never written back, temporarily widen the time window, or run a one-shot compensation task to backfill the missing order numbers. Then immediately switch back to the incremental window.
Phase 4: Scheduling cadence Source every 10 minutes, target every 1 minute. We have validated this dual-track arrangement of incremental and full-volume scheduling on several customer sites — the source scans at low frequency, the target executes at high frequency, which keeps latency low while smoothing API pressure.
Pitfalls and Lessons Learned
1. Hardcoded field codes. The target ERP-number field field_s1lUM__c is a tenant custom field that varies across environments. A common mistake is copying screenshots from elsewhere. The safe approach on Qeasy is to centralize mappings and treat field codes as configuration items.
2. Unenforced dependency order. If the source fires before the predecessor strategy, primaryWriteback is still empty and the lookup returns null. On customer sites we often delay the source by a few minutes, or have the predecessor skip writing primaryWriteback on failure.
3. Writeback triggering workflows. In one project we forgot triggerWorkFlow=false, and every single order-number writeback kicked off a CRM workflow, overwhelming the approvers. Writeback strategies must explicitly disable both workflow and approval triggers.
4. Detail lines being overwritten. details = _Flist is a passthrough semantic. If the target update API merges or overwrites line items, existing details can be clobbered. Verify how the target update API treats details first, and consider leaving details empty to only update the header.
5. Drifting time windows. {{LAST_SYNC_TIME}} can jump on retry, causing windows to miss records. We usually add a fallback rerun mechanism on customer sites to recover any missed status=2 records.
When to Use and When Not to Use
Use when: CRM and ERP need bidirectional linkage, when the ERP order number must be written back to CRM for reconciliation, traceability, or cross-system jumps, and when updates are lightweight key-based patches. Do not use when: the requirement is to insert or modify line items, trigger approvals or workflows on the CRM side, or batch write back across multiple orgs or books — those scenarios deserve their own dedicated sync strategy and should not be mixed with order-number writeback.