Authoritative Tutorial on the Kingdee Cloud Department Query Interface Field Manual
What Problem This Interface Solves
In integration scenarios between Kingdee Cloud and collaboration platforms such as DingTalk, department master data serves as the foundation for organizational structure synchronization, employee mapping, and approval-flow department selection. This interface is used to query department master data from Kingdee Cloud. It operates in a query-only mode and does not write back to any target system. It is typically used as an upstream basic-data synchronization strategy, providing the "department" dimension for downstream business documents such as employees, customers, and sales orders.
Interface Capability Overview
- Authentication: Called via the Kingdee Cloud WebAPI. The authorization ticket is carried in the request header. In Qeasy, this is usually encapsulated in the adapter's authentication configuration and does not need to be handled manually.
- Request Method: POST, with the interface name ExecuteBillQuery and the form ID BD_Department.
- Response Structure: Returns a JSON array where each element corresponds to a department record. Core fields include FDEPTID, FNumber, FName, FCreateOrgId, and FUseOrgId.
- Pagination: ExecuteBillQuery controls the number of records returned per page through pagination parameters. Cross-page queries must combine incremental timestamps or primary-key cursors to enable breakpoint resumption.
- Incremental Mode: The FilterString takes the form
FAuditDate>='{{LAST_SYNC_TIME|datetime}}' and FForbidStatus='A', which synchronizes only departments whose audit date is later than the last sync time and whose enable status is A. - Scheduling Strategy: A common configuration is
*/3 8-23 * * *, meaning every 3 minutes from 08:00 to 23:00, avoiding frequent pulls during low-traffic nighttime hours.
Typical Field Mapping
| Field Name | Type | Business Meaning | Practical Notes |
|---|---|---|---|
| FDEPTID | string | Department primary key, uniquely identifies a department record | Configured as the id field in Qeasy metadata, used as the cross-system correlation key |
| FNumber | string | Department business code | Prefer FNumber for cross-system (e.g., DingTalk) matching instead of FName |
| FName | string | Department display name | Configured as the number field in metadata, used for business display |
| FCreateOrgId | string | ID of the organization that created the department | Determines the data isolation scope in multi-organization scenarios |
| FUseOrgId | string | ID of the organization that uses the department | May differ from the creating organization when departments are shared |
| FAuditDate | datetime | Audit date | Core timestamp field for incremental synchronization |
| FForbidStatus | string | Disable status, A=Enabled/B=Disabled | Must be included in FilterString to avoid syncing disabled departments |
How to Configure on Qeasy
In the Qeasy Data Integration Platform, this interface is encapsulated as a query action of the Kingdee Cloud adapter. The configuration flow is roughly as follows:
- Create a Query Strategy: Select "Kingdee Cloud" as the source system, choose the platform itself as the target, and set the strategy type to QUERY_ONLY.
- Configure Request Parameters: Fill in the interface name ExecuteBillQuery and form ID BD_Department in the adapter, and set the field selector to return the required columns from the master table.
- Configure FilterString: Write
FAuditDate>='{{LAST_SYNC_TIME|datetime}}' and FForbidStatus='A'into the incremental condition. The platform will automatically inject the last sync time at each execution. - Field Mapper: The Qeasy field mapper automatically recognizes the FDEPTID and FNumber returned by Kingdee and generates the id and number fields according to the metadata configuration, eliminating the need for manual mapping of basic keys.
- Scheduled Dispatch: Configure the crontab as
*/3 8-23 * * *in the dispatch center. The platform will automatically maintain the LAST_SYNC_TIME variable. - Downstream Connection: This strategy only produces department master data to the platform's transit layer. Subsequent employee and order synchronization strategies can perform association queries using FNumber.
Cross-Scenario Best Practices
- Prefer FNumber over FName as the Primary Key: FName is often merged or renamed during organizational adjustments, while FNumber is the stable business identifier. Cross-system matching must rely on codes.
- Incremental Queries Must Include FForbidStatus='A': Disabled departments should not be pushed downstream to DingTalk, otherwise dirty data such as "active in DingTalk but disabled in Kingdee" will occur.
- Distinguish Create and Use Organizations in Multi-Org Scenarios: FCreateOrgId determines the permission boundary, and FUseOrgId determines visibility. They must not be mixed when performing permission-based synchronization.
- Use the Audit Date as the Incremental Baseline: FAuditDate is more reliable than the creation date. Newly created but unaudited departments should not be pushed in advance.
- Dual Protection with Pagination and Increment: In addition to relying on LAST_SYNC_TIME in cross-page scenarios, the last FDEPTID should also be recorded to avoid missing records when multiple records share the same LAST_SYNC_TIME second.
- Scheduling Window Should Match Business Hours: The rhythm of every 3 minutes from 08:00 to 23:00 has been verified across multiple scenarios to ensure timeliness while avoiding Kingdee's nighttime batch processing.
Pitfall Retrospective
- FForbidStatus Filter Omitted, Disabled Departments Synced to DingTalk: This led to disabled departments being selectable in DingTalk approvals, making subsequent permission reclamation difficult. The safe approach is to always force
FForbidStatus='A'into the FilterString. - Using FName as the Primary Key, Breaking All Downstream Links After a Rename: Once FName changes, all downstream data correlated by name (employees, approval templates) loses connection. This is easy to trip on. The safe approach is to always use FDEPTID or FNumber as the primary key and treat FName only as a display field.
- LAST_SYNC_TIME Time-Zone Drift: When the Kingdee server and the Qeasy scheduler are in different time zones, incremental queries will either pull duplicates or miss records. It is recommended to explicitly format the timestamp in the FilterString or unify the platform time zone.
- Forgetting to Pass the Last Maximum FDEPTID in Cross-Page Queries: When multiple records are audited within the same minute and share the same LAST_SYNC_TIME, records can easily be missed. The safe approach is to overlay a primary-key cursor when paginating.
- Failure to Configure Multi-Organization Differentiation, Causing Incorrect Cross-Org Department Sharing: When FCreateOrgId and FUseOrgId differ, omitting the filter will sync Organization A's departments to Organization B, resulting in data over-permission.
When to Use
This interface is suitable for integration scenarios where Kingdee Cloud serves as the sole source of organizational structure, especially Kingdee ↔ DingTalk collaboration, organizational structure synchronization, and approval-flow department selection. If the enterprise uses another system (such as HR or OA) as the source of organizational structure, or if department data is jointly maintained by multiple systems, a bidirectional synchronization scheme should be considered first instead of a single query interface.