Syncing Feishu Approval Instances into MySQL: A Field Guide for Loan Request Forms
What This Strategy Solves
In many organizations, employee loan requests are submitted through Feishu approvals, but the ledger, fund-occupation analysis, and payment reconciliation all live in a business database (MySQL). When approval results never reach the database, finance teams end up exporting form data manually, which is slow and error-prone. What we build here is a stable pipeline that pushes Feishu approval instances into MySQL by their serial number, turning loan requests into queryable, joinable, and reusable structured records.
Data Flow and Field Mapping
The flow is straightforward: Feishu (approval instance) → Qeasy middleware → MySQL business table. The source side uses Feishu's Open API for approval instances, while the target side writes to MySQL via a batchexecute SQL.
Key source fields (exposed as widget IDs from the approval form):
serial_number: approval instance number, used as the business keyinstance_code: approval instance ID, used for idempotencyapplicant(from a widget field): the requesterloan_type(from the_text-suffixed field): loan type, where the_textsuffix carries the display labelrelated_unit_type: counterparty typeexplanation_2: explanation field
Target MySQL columns:
serial_number— codeinstance_code— approval idapplicant— requesterloan_type— loan typerelated_unit_type— counterparty typeexplanation_2— explanation
The most common trap in mapping is option-type fields. Feishu widgets return display text in the _text variant, not the underlying enum. Storing raw text in MySQL kills downstream analytics. The robust approach is to maintain a centralized mapping table in Qeasy, translate the display label (travel / petty cash / procurement, etc.) into a business dictionary code, store the dictionary code in MySQL, and redundantly keep the label in a separate display column.
Configuring It in Qeasy
In Qeasy, we structure this strategy into three segments: source read + transformation + target write.
- Source platform: choose Feishu, select the
/open-apis/approval/v4/instancesendpoint, method GET. Bindapproval_codeto the loan-request form's ID. Use{{CURRENT_TIME}}000placeholders forstart_time/end_timeso Qeasy fills the time window automatically based on the scheduling context, instead of maintaining it manually. - Transformation layer: in Qeasy's field mapping, rename widget fields into target column names (
applicant,loan_type, etc.), run the_textfields through the mapping table to produce dictionary codes, and enableidCheckusingserial_numberas the primary key to prevent duplicate writes. - Target platform: choose MySQL, execution type SQL, write via
batchexecutein batch mode. Setcrontabto* * * * *for near-real-time landing on the target side.
The source crontab is intentionally set to 1 1 1 1 1 (placeholder), because the real time windows are managed by Qeasy's unified scheduler rather than embedded in the API request. This "the source only fetches, the platform orchestrates" pattern is one we have iterated on with many customers.
Implementation Steps
We recommend rolling this out in three phases rather than a big bang:
- Phase 1 — Full backfill. Manually trigger a full pull in Qeasy and replay historical approval instances into MySQL in time-windowed batches. The focus here is validating field mapping, dictionary codes, and character set issues (Feishu emojis and rare-character names most often expose MySQL's charset limits at this step).
- Phase 2 — Align the incremental starting point. Configure the incremental start timestamp in Qeasy as "last full-load end time + 1 second" and persist this value in a config table. Never use vague starts like "current time minus N minutes" — missed records are almost guaranteed otherwise.
- Phase 3 — Steady-state scheduling. The source pulls increments on a business-driven cadence (e.g. every minute), and the target lands via
* * * * *. After one week, reconcile the totalserial_numbercount in MySQL against Feishu's approved-instance report; the delta must be zero.
Source reads are scheduling-driven and target writes are also scheduling-driven — this is the typical "dual-track full + incremental" model: full loads for initial backfill and recovery, incremental for day-to-day.
Pitfalls From the Field
- Storing
_textsuffix fields directly. A classic mistake is writingwidgetxxx_textverbatim into MySQL, which leavesloan_typeas plain text and breaks enum-based aggregation. The robust approach is mapping to dictionary codes in Qeasy and redundantly storing labels in a display column. - Drifting incremental start. Using
{{CURRENT_TIME}}directly as the start looks fine but shifts the window every run, so approvals that were just submitted but not yet approved keep reappearing. The robust approach is filtering on approval completion time, not submission time. idCheckdisabled causes duplicates. When Feishu instances are pulled multiple times, missing primary-key checks produces duplicateserial_numberrows in MySQL. The robust approach isidCheck=trueon the target, converting primary-key conflicts into updates rather than inserts.- Time-window truncation across days. Feishu's API caps
end_time; overly wide windows get truncated. The robust approach is shrinking the per-call window and slicing it by hour or day inside Qeasy. - Charset and null semantics. Feishu names can contain emojis or rare characters; if MySQL is not
utf8mb4, writes fail. When the requester field is empty, decide explicitly between empty string and NULL so downstream metrics stay consistent.
When to Use It — and When Not To
Use it when: Feishu approval results need to land in a business database for ledger, reporting, or reconciliation; the form fields are relatively stable; and the daily volume is manageable (under ~1,000 instances per day).
Don't use it when: the approval form's fields change frequently or widget IDs are reused; or when real-time requirements are sub-second and volumes are very high — in those cases, prefer event-driven pushes plus streaming writes instead of polling.