Purchase Order Cancel Sync in Practice: Dingtalk Approval Revoke → Kingdee Cloud CancelAssign
What This Strategy Solves
In the procurement workflow of a manufacturing enterprise, a purchase order is first created and audited in Kingdee Cloud, then routed through an approval flow into Dingtalk for downstream confirmation. As soon as the applicant withdraws the request or an approver revokes it on Dingtalk, the order on the Kingdee side must be synchronized into a cancelled state. Otherwise, you end up with orphan orders—already withdrawn in Dingtalk but still alive in Kingdee. This strategy pushes that single revoke action cleanly from Dingtalk into Kingdee.
Data Flow and Field Mapping
Data flow: Dingtalk approval instance → Qeasy (intermediate layer) → Kingdee Cloud CancelAssign. The source is not the order itself but an approval event; the target is not a write but an execution.
| Source (Dingtalk form/API) | Target (Kingdee request body) | Mapping Type | Notes |
|---|---|---|---|
| Form control "BillNo" | Numbers | DIRECT | {{BillNo}}, passed in as the number collection |
| — | Ids | COLLECTION | _findCollection find FID from {{queryPlanId}} where FBillNo={{BillNo}}, lookup FID by bill number |
| — | FormId | CONSTANT | PUR_PurchaseOrder, Kingdee purchase order business object form ID |
| — | IgnoreInterationFlag | CONSTANT | true, allow ignoring interactive prompts to prevent blocking dialogs |
| — | NetworkCtrl | CONSTANT | false, disable network control |
| — | IsVerifyProcInst | CONSTANT | false, skip workflow instance verification |
The two most critical columns are Numbers and Ids. Kingdee's cancel API accepts either a bill number or an FID, so the safe practice is to fill both—the number comes from the form, the FID from the lookup; whichever hits will land the operation.
How to Configure on Qeasy
In the Qeasy integration platform's strategy editor, configure the following key points:
- Source side: pick "Dingtalk" as the platform, choose
topapi/processinstance/getas the API, set effect toQUERY, withidas the primary key. In the response list, check "BillNo" and mark_autoFillResponsein the describe field so that the Dingtalk form control value is auto-filled into the variable. - Target side: pick "Kingdee Cloud" as the platform, choose
CancelAssignas the API, set effect toEXECUTE. SetFormIdto the constantPUR_PurchaseOrder; reference{{BillNo}}directly forNumbers; forIds, use the COLLECTION type and the expression_findCollection find FID from {{queryPlanId}} where FBillNo={{BillNo}}. - Lookup dependency: ensure a "Query Kingdee Purchase Order" plan already exists on Qeasy. That is the data source for
_findCollection. The audit and cancel strategies can share the same query plan—a common pattern we use when delivering to customers: centralize all "find FID by bill number" needs in a single query plan so other strategies only reference rather than duplicate it. - Scheduling: set both sides to
*/3 * * * *. The source polls every 3 minutes for new/changed approval instances, and the target executes in lockstep. Cancel is a low-frequency action; 3-minute granularity is enough, no need to drop to 1 minute. - Switch: explicitly set
IgnoreInterationFlagtotrue. This is standard practice for cancel-type strategies—otherwise Kingdee may pop up interaction dialogs and the task will hang.
Implementation Steps
- Pre-build the lookup plan: first create a "Query Kingdee Purchase Order" plan on Qeasy and confirm it can return
FIDbyFBillNo. This is the shared foundation used by both the audit and cancel strategies. - Land the cancel strategy: create the strategy per the previous section. Manually trigger once to verify
_findCollectionreturns an FID and CancelAssign succeeds. - Configure the incremental starting point: deduplicate on the source side using "approval instance id" and only process instances whose state has changed to "revoked/withdrawn" to avoid duplicate executions.
- Full-trigger sweep: at first go-live, run a one-shot full scan to backfill historical orphans—orders already withdrawn in Dingtalk but still open in Kingdee. Then switch back to incremental.
- Scheduling cadence: keep both sides polling every 3 minutes. If approval volume is high, the source can be tightened to 1 minute while the target stays at 3 minutes, forming an "upstream fast, downstream steady" rhythm.
- Verification: within the first week after go-live, sample 3–5 orders daily and compare Dingtalk status against Kingdee status to confirm linkage is correct, then relax monitoring.
Pitfalls and Lessons Learned
- BillNo cannot be obtained and cancel fails outright. Dingtalk's
topapi/processinstance/getreturns the approval structure, andBillNohides inform_component_valuesorextend. Be sure to configure_autoFillResponsein the source response; otherwise the downstream{{BillNo}}will be an empty string and Kingdee will reject with "Numbers cannot be empty". - Passing only Numbers without Ids causes intermittent failures. In some Kingdee versions, when the bill number carries a prefix (e.g.,
PO-2024-xxx), pure number matching fails. The safe practice is to pass Numbers and Ids together and let Kingdee decide—this is the default in our customer projects. _findCollectionsyntax errors cause empty results. A typical mistake is adding spaces inwhere FBillNo = {{BillNo}}or using the wrong plan ID. The syntax is space-sensitive—no spaces between field name and value—and the plan ID must be accessible within the current tenant.IgnoreInterationFlagnot set to true, task hangs forever. Cancel in some validation scenarios triggers interactive prompts; without ignoring them, async tasks get suspended. The symptom is "strategy keeps running but produces no result".- Audit and cancel share the lookup plan, but updates get forgotten. If fields in the query plan change, both audit and cancel break at the same time. Whenever you share a foundation, change one place and regression-test both—this is the discipline cost of centralized management.
When to Use and When Not to Use
Use when: Dingtalk is the approval entry point and Kingdee is the business system, and approval state must drive business documents in reverse (cancel, unaudit, close). Do not use when: Dingtalk lacks a "BillNo" form control, or the Kingdee order has already triggered downstream transactions (e.g., goods received, warehoused) that prevent direct cancellation. In those cases, downstream cleanup must run first before invoking cancel.