CRITICAL — Before starting, MUST first use the Read tool to read ../lark-shared/SKILL.md, which contains authentication and permission handling
Applicable Scenarios
- "Help me create an inventory management system" / "set up inventory management" / "create new inventory management"
- "Add product: beige T-shirt, sizes S/M/L" / "add SKU"
- "Inbound: beige T-shirt 10 pieces, unit price 50" / "purchase registration"
- "Outbound: beige T-shirt 3 pieces, purpose requisition" / "shipment outbound"
- "Check the inventory of beige T-shirts" / "inventory list" / "which products have insufficient inventory"
- "low inventory alert" / "inventory alarm" / "out-of-stock reminder"
- "this month's inbound summary" / "outbound statistics" / "inventory report" / "slow-moving analysis"
- "add supplier" / "supplier list"
- "create inventory dashboard" / "inventory dashboard"
Prerequisites
Only supports user identity. Before execution, ensure authorization:
lark-cli auth login --domain base,im,docs
System Architecture
进销存 ERP (lark-workflow-erp-inventory)
│
├── 数据层:飞书多维表格 (Bitable)
│ ├── 货品库存台账 (products) — SKU 主数据
│ ├── 入库记录表 (stock_in) — 入库流水
│ ├── 出库记录表 (stock_out) — 出库流水
│ └── 供应商表 (suppliers) — 供应商信息(扩展)
│
├── 计算层
│ ├── 累计入库 (lookup) — 从入库表按物品名称汇总入库数量
│ ├── 累计出库 (lookup) — 从出库表按物品名称汇总出库数量
│ ├── 剩余库存 (formula) — 累计入库 - 累计出库
│ ├── 库存状态 (formula) — IF(剩余库存 ≤ 最低库存, "低库存", "正常")
│ └── 入库金额 (formula) — 入库数量 × 入库单价
│
├── 关联关系
│ ├── 入库表.关联物品 ↔ 台账(双向)
│ ├── 出库表.关联物品 ↔ 台账(双向)
│ └── 台账.供应商 ↔ 供应商表(双向)
│
├── 交互层:用户自然语言指令
│ ├── 系统初始化 → 创建 Base + 表 + 字段 + 关联
│ ├── 日常操作 → 入库/出库/查询
│ └── 数据分析 → 聚合统计 + 报表
│
└── 通知层:飞书消息
├── 低库存预警通知
└── 出库确认通知
Agent Core Rules
- Must verify inventory before outbound — first query the remaining inventory in the ledger table; if insufficient, block and notify the user
- Only use
lark-cli base +...atomic commands — do not go throughlark-cli apidirect calls - When creating a table, you must first create an empty table and then add fields one by one —
+table-createwith--fieldsmultiple fields easily triggers rate limiting (error code 800004135); instead, first create an empty table, then use+field-createto add fields one by one, with a 1.5-second interval each time - Link fields must use bidirectional links —
bidirectional: true, otherwise cross-table aggregation in formulas is not possible - Inventory calculation uses a combination of lookup + formula — do not use formula fields to directly query across tables (it will become a full-table SUM); instead, use lookup fields for cross-table aggregation, then use formula fields for difference calculation
+data-queryput the table-id in the DSL — does not support--table-idparameter; it needs to be placed in--dslthedatasource.table.tableIdof+data-queryonly supports storage fields — does not support formula fields, lookup fields, or link fields for aggregation- Get the field structure before writing records —
+field-listto confirm field names and types - Read the guide before creating formula fields — read
../lark-base/references/formula-field-guide.md +xxx-listconcurrency is prohibited — all list commands are executed serially- Serial writes + intervals —
+record-upsertserially, with a 0.5-1 second interval - Paginated fetching —
+record-list --limit 200, using offset pagination - Exact matching of table names/field names — guessing based on natural language is prohibited; it must come from
+table-list/+field-listthe return value
Phase 1: System Initialization
Step 1.1: Create Base
lark-cli base +base-create --name "进销存管理系统" --as user
Record the returned base_token(all subsequent commands require this).
Step 1.2: Create data tables (create empty tables first, with a 2-second interval)
IMPORTANT: Do not use the
--fieldsparameter to create multiple fields at once, as it easily triggers rate limiting. First create an empty table, then use+field-createto add fields one by one.
# 表 1:货品库存台账
lark-cli base +table-create --base-token "<base_token>" --name "货品库存台账" --as user
sleep 2
# 表 2:供应商
lark-cli base +table-create --base-token "<base_token>" --name "供应商" --as user
sleep 2
# 表 3:入库记录
lark-cli base +table-create --base-token "<base_token>" --name "入库记录" --as user
sleep 2
# 表 4:出库记录
lark-cli base +table-create --base-token "<base_token>" --name "出库记录" --as user
Step 1.3: Get the table_id of each table
lark-cli base +table-list --base-token "<base_token>" --as user
Record the table_id。
Step 1.4: Add storage fields one by one (with a 1.5-second interval between each creation)
Ledger table fields
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"auto_number","name":"物品编号","style":{"rules":[{"type":"text","text":"SKU-"},{"type":"incremental_number","length":4}]}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"text","name":"物品名称"}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"text","name":"规格型号"}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"select","name":"类别","options":[{"name":"服装"},{"name":"电子产品"},{"name":"食品"},{"name":"办公用品"},{"name":"其他"}]}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"select","name":"单位","options":[{"name":"件"},{"name":"个"},{"name":"箱"},{"name":"套"},{"name":"kg"}]}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"number","name":"最低库存","style":{"type":"plain","precision":0}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"number","name":"单价","style":{"type":"currency","precision":2,"currency_code":"CNY"}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" --json '{"type":"text","name":"备注"}' --as user
sleep 2
Supplier table fields
lark-cli base +field-create --base-token "<base_token>" --table-id "<suppliers_table_id>" --json '{"type":"text","name":"供应商名称"}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<suppliers_table_id>" --json '{"type":"text","name":"联系人"}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<suppliers_table_id>" --json '{"type":"text","name":"联系电话","style":{"type":"phone"}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<suppliers_table_id>" --json '{"type":"text","name":"地址"}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<suppliers_table_id>" --json '{"type":"select","name":"供应类别","options":[{"name":"服装"},{"name":"电子产品"},{"name":"食品"},{"name":"办公用品"},{"name":"其他"}]}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<suppliers_table_id>" --json '{"type":"select","name":"合作状态","options":[{"name":"合作中"},{"name":"暂停"},{"name":"终止"}]}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<suppliers_table_id>" --json '{"type":"text","name":"备注"}' --as user
sleep 2
Inbound record table fields
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"auto_number","name":"入库单号","style":{"rules":[{"type":"text","text":"IN-"},{"type":"incremental_number","length":4}]}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"text","name":"供应商"}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"number","name":"入库数量","style":{"type":"plain","precision":0}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"number","name":"入库单价","style":{"type":"currency","precision":2,"currency_code":"CNY"}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"select","name":"用途","options":[{"name":"采购"},{"name":"退货"},{"name":"调拨"},{"name":"盘盈"},{"name":"其他"}]}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"user","name":"入库人","multiple":false}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"datetime","name":"入库日期","style":{"format":"yyyy-MM-dd"}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" --json '{"type":"text","name":"备注"}' --as user
sleep 2
Outbound record table fields
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_out_table_id>" --json '{"type":"auto_number","name":"出库单号","style":{"rules":[{"type":"text","text":"OUT-"},{"type":"incremental_number","length":4}]}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_out_table_id>" --json '{"type":"number","name":"出库数量","style":{"type":"plain","precision":0}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_out_table_id>" --json '{"type":"user","name":"领用人","multiple":false}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_out_table_id>" --json '{"type":"datetime","name":"出库日期","style":{"format":"yyyy-MM-dd"}}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_out_table_id>" --json '{"type":"select","name":"用途","options":[{"name":"销售"},{"name":"领用"},{"name":"调拨"},{"name":"盘亏"},{"name":"其他"}]}' --as user
sleep 1.5
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_out_table_id>" --json '{"type":"text","name":"备注"}' --as user
sleep 2
Step 1.5: Create bidirectional link fields (with a 2-second interval between each creation)
CRITICAL: Link fields must use
bidirectional: true, otherwise cross-table aggregation cannot be done in formulas/lookups.
Ledger → Supplier link
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" \
--json '{"type":"link","name":"供应商","link_table":"供应商","bidirectional":true,"bidirectional_link_field_name":"供应货品"}' \
--as user
sleep 2
Inbound table → Ledger link (bidirectional)
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" \
--json '{"type":"link","name":"关联物品","link_table":"货品库存台账","bidirectional":true,"bidirectional_link_field_name":"入库记录"}' \
--as user
sleep 2
Outbound table → Ledger link (bidirectional)
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_out_table_id>" \
--json '{"type":"link","name":"关联物品","link_table":"货品库存台账","bidirectional":true,"bidirectional_link_field_name":"出库记录"}' \
--as user
sleep 2
Step 1.6: Create lookup + formula calculated fields
IMPORTANT:
- Before creating a formula field, you MUST first read
../lark-base/references/formula-field-guide.md- Before creating a lookup field, you MUST first read
../lark-base/references/lookup-field-guide.md- All calculated field creation commands need to append
--i-have-read-guide
Inventory calculation architecture: lookup fields perform cross-table aggregation → formula fields perform difference calculation
- Cumulative inbound(lookup field): aggregate the inbound quantity corresponding to the current item name from the inbound table
- Cumulative outbound(lookup field): aggregate the outbound quantity corresponding to the current item name from the outbound table
- Remaining inventory(formula field): cumulative inbound - cumulative outbound
- Inventory status(formula field): IF(remaining inventory ≤ minimum inventory, "low inventory", "normal")
- Inbound amount(formula field): inbound quantity × inbound unit price
Ledger table: cumulative inbound (lookup)
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" \
--json '{"type":"lookup","name":"累计入库","from":"入库记录","select":"入库数量","where":{"logic":"and","conditions":[["关联物品","==",{"type":"field_ref","field":"物品名称"}]]},"aggregate":"SUM"}' \
--i-have-read-guide \
--as user
sleep 2
lookup description:
fromspecifies the source table name,selectspecifies the field to aggregate,whereinfield_refreferences the current table's item name field to match the source table's link field,aggregate: "SUM"sum.
Ledger table: cumulative outbound (lookup)
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" \
--json '{"type":"lookup","name":"累计出库","from":"出库记录","select":"出库数量","where":{"logic":"and","conditions":[["关联物品","==",{"type":"field_ref","field":"物品名称"}]]},"aggregate":"SUM"}' \
--i-have-read-guide \
--as user
sleep 2
Ledger table: remaining inventory (formula)
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" \
--json '{"type":"formula","name":"剩余库存","expression":"IFBLANK([累计入库], 0) - IFBLANK([累计出库], 0)"}' \
--i-have-read-guide \
--as user
sleep 2
Ledger table: inventory status (formula)
lark-cli base +field-create --base-token "<base_token>" --table-id "<products_table_id>" \
--json '{"type":"formula","name":"库存状态","expression":"IF([剩余库存] <= [最低库存], \"低库存\", \"正常\")"}' \
--i-have-read-guide \
--as user
sleep 2
Inbound table: inbound amount (formula)
lark-cli base +field-create --base-token "<base_token>" --table-id "<stock_in_table_id>" \
--json '{"type":"formula","name":"入库金额","expression":"[入库数量] * [入库单价]"}' \
--i-have-read-guide \
--as user
Phase 2: Daily operations
2.1 Add goods
lark-cli base +record-upsert --base-token "<base_token>" --table-id "<products_table_id>" \
--json '{"物品名称":"米色T恤","规格型号":"S/M/L/XL","类别":"服装","单位":"件","最低库存":5,"单价":50,"备注":"夏季新款"}' \
--as user
Agent processing logic:
- Parse user input: extract item name, specification, category, unit, minimum inventory, unit price, remarks
- Leave fields not provided empty or use default values
- Category/unit must match existing options; if not among the options, remind the user
2.2 Modify goods information
# 先查询获取 record_id
lark-cli base +record-list --base-token "<base_token>" --table-id "<products_table_id>" --as user
# 更新货品信息
lark-cli base +record-upsert --base-token "<base_token>" --table-id "<products_table_id>" \
--record-id "<record_id>" \
--json '{"最低库存":10,"备注":"更新备注"}' \
--as user
Agent processing logic:
- Query record_id based on the item name/number provided by the user
- Only update the fields specified by the user (Delta update)
2.3 Inbound operation
lark-cli base +record-upsert --base-token "<base_token>" --table-id "<stock_in_table_id>" \
--json '{"关联物品":["<record_id>"],"入库数量":10,"入库单价":50,"用途":"采购","入库日期":<timestamp_ms>,"备注":"正常采购"}' \
--as user
Link field value format: The value of a link field is an array of record_id, such as
["recXXXX"]。 Date format: Date fields use Unix millisecond timestamps (numbers), not strings.
Agent processing logic:
- Parse user input: extract item name, inbound quantity, unit price, purpose/source
- Query the ledger table for the item's corresponding record_id
- Date defaults to the current day (
Date.now()millisecond timestamp) - Write the inbound record
- Reply to the user: inbound successful, and display the updated remaining inventory
Inbound success reply format:
入库成功!
物品:米色T恤
入库数量:10 件
入库单价:50.00 元
入库金额:500.00 元
用途:采购
日期:2024-01-15
当前剩余库存:10 件
2.4 Outbound operation (including inventory validation)
Inventory validation must be performed before outbound:
# Step 1: 查询物品当前库存
lark-cli base +record-list --base-token "<base_token>" --table-id "<products_table_id>" --as user
# 从返回结果中找到目标物品的 record_id 和剩余库存值
# Step 2: 校验库存
# 如果 剩余库存 < 出库数量 → 拦截并提示
# 如果 剩余库存 >= 出库数量 → 执行出库
# Step 3: 执行出库
lark-cli base +record-upsert --base-token "<base_token>" --table-id "<stock_out_table_id>" \
--json '{"关联物品":["<record_id>"],"出库数量":3,"用途":"领用","出库日期":<timestamp_ms>,"备注":""}' \
--as user
Agent processing logic:
- Parse user input: extract item name, outbound quantity, purpose, recipient
- Query the ledger table to obtain the item's record_id and remaining inventory
- Validate: remaining inventory >= outbound quantity?
- Insufficient → prompt
"库存不足!米色T恤 当前剩余库存仅 X 件,无法出库 Y 件。"and abort - Sufficient → continue outbound
- Insufficient → prompt
- Write the outbound record
- Reply to the user
Insufficient inventory interception format:
出库失败 - 库存不足!
物品:米色T恤
当前剩余库存:2 件
请求出库数量:3 件
缺少:1 件
Outbound success reply format:
出库成功!
物品:米色T恤
出库数量:3 件
用途:领用
日期:2024-01-15
出库前库存:10 件
出库后库存:7 件
2.5 Query inventory
Query a single item's inventory
lark-cli base +record-list --base-token "<base_token>" --table-id "<products_table_id>" --as user
# AI 从返回结果中筛选目标物品
Reply format:
物品库存查询
物品名称:米色T恤
规格型号:S/M/L/XL
类别:服装
累计入库:10 件
累计出库:3 件
剩余库存:7 件
最低库存:5 件
库存状态:正常
单价:50.00 元
Query the full inventory list
lark-cli base +record-list --base-token "<base_token>" --table-id "<products_table_id>" \
--limit 200 --as user
# 如超过 200 条,用 offset 分页
Reply format:
库存清单(共 N 种货品)
| 物品名称 | 规格 | 剩余库存 | 最低库存 | 状态 | 单价 |
|---------|------|---------|---------|------|------|
| 米色T恤 | S/M/L | 7 件 | 5 件 | 正常 | 50.00 |
| 黑色外套 | M/L | 2 件 | 10 件 | ⚠️低库存 | 200.00 |
⚠️ 低库存预警:1 种货品低于最低库存
2.6 Query inbound/outbound records
# 入库记录
lark-cli base +record-list --base-token "<base_token>" --table-id "<stock_in_table_id>" \
--limit 200 --as user
# 出库记录
lark-cli base +record-list --base-token "<base_token>" --table-id "<stock_out_table_id>" \
--limit 200 --as user
Agent processing:
- If the user specified an item name, filter the corresponding records from the returned results
- If the user specified a time range, filter by date
- Organize into an easy-to-read table format for the reply
2.7 Delete goods/records
lark-cli base +record-delete --base-token "<base_token>" --table-id "<products_table_id>" \
--record-id "<record_id>" --yes --as user
Note: Before deleting goods, the user should be reminded that the associations in the inbound/outbound records related to that goods will be affected.
Phase 3: Inventory alerts and notifications
3.1 Low inventory detection
lark-cli base +record-list --base-token "<base_token>" --table-id "<products_table_id>" \
--limit 200 --as user
# AI 筛选 库存状态 = "低库存" 的记录
Reply format:
低库存预警报告
以下 N 种货品库存低于最低库存:
| 物品名称 | 当前库存 | 最低库存 | 缺少 | 单价 | 库存金额 |
|---------|---------|---------|------|------|---------|
| 黑色外套 | 2 件 | 10 件 | 8 件 | 200.00 | 400.00 |
| 蓝色牛仔裤 | 0 件 | 10 件 | 10 件 | 150.00 | 0.00 |
建议及时补货。
3.2 Send alert notifications to the Feishu group
lark-cli im +messages-send --chat-id "<chat_id>" \
--msg-type "interactive" \
--content '{
"config": {"wide_screen_mode": true},
"header": {"title": {"tag": "plain_text", "content": "低库存预警"}, "template": "red"},
"elements": [
{"tag": "div", "text": {"tag": "lark_md", "content": "以下货品库存低于最低库存,请及时补货:"}},
{"tag": "div", "text": {"tag": "lark_md", "content": "**黑色外套** 当前 2 件 / 最低 10 件\n**蓝色牛仔裤** 当前 0 件 / 最低 10 件"}}
]
}' \
--as user
Important: Before sending a message, you must first read
../lark-im/SKILL.mdto understand the message sending rules.
3.3 Outbound confirmation notification
After outbound is completed, if the user requests a notification to be sent:
lark-cli im +messages-send --chat-id "<chat_id>" \
--msg-type "interactive" \
--content '{
"config": {"wide_screen_mode": true},
"header": {"title": {"tag": "plain_text", "content": "出库确认通知"}, "template": "blue"},
"elements": [
{"tag": "div", "text": {"tag": "lark_md", "content": "已成功出库:"}},
{"tag": "div", "text": {"tag": "lark_md", "content": "**物品**:米色T恤\n**数量**:3 件\n**用途**:领用\n**领用人**:@用户"}}
]
}' \
--as user
Phase 4: Data analysis
4.1 Inbound summary
IMPORTANT:
+data-querydoes not support the--table-idparameter; table-id must be placed in the--dslofdatasource. And only stored fields are supported (formula fields, lookup fields, and linked fields are not supported).
lark-cli base +data-query --base-token "<base_token>" \
--dsl '{
"datasource": {"type": "table", "table": {"tableId": "<stock_in_table_id>"}},
"dimensions": [{"field_name":"用途","alias":"usage_type"}],
"measures": [
{"field_name":"入库数量","aggregation":"sum","alias":"total_qty"},
{"field_name":"入库单价","aggregation":"avg","alias":"avg_price"}
]
}' \
--as user
Note: Do not aggregate formula fields (such as "inbound amount"), as it will cause an error. Instead, perform SUM on "inbound quantity" and AVG on "inbound unit price".
Reply format:
入库汇总
| 用途 | 入库数量 | 平均单价 |
|------|---------|---------|
| 采购 | 33 件 | 133.33 元 |
| **合计** | **33 件** | |
4.2 Outbound summary
lark-cli base +data-query --base-token "<base_token>" \
--dsl '{
"datasource": {"type": "table", "table": {"tableId": "<stock_out_table_id>"}},
"dimensions": [{"field_name":"用途","alias":"usage_type"}],
"measures": [{"field_name":"出库数量","aggregation":"sum","alias":"total_qty"}]
}' \
--as user
4.3 Slow-moving analysis
lark-cli base +record-list --base-token "<base_token>" --table-id "<products_table_id>" \
--limit 200 --as user
Agent processing logic:
- Pull ledger data to obtain each item's cumulative inbound and remaining inventory (lookup field values)
- Calculate outbound quantity = cumulative inbound - remaining inventory
- Filter out goods whose outbound quantity is 0 or below the threshold
- Sort by inventory amount
4.4 Generate inventory report document
lark-cli docs +create --title "库存报表 - 2024年1月" --markdown "<报表内容>" --as user
4.5 Create inventory dashboard (dashboard)
lark-cli base +dashboard-create --base-token "<base_token>" --name "库存看板" --as user
Note: For dashboard configuration, you must first read
../lark-base/references/dashboard-block-data-config.mdto understand the data_config structure.
Phase 5: Supplier management
5.1 Add supplier
lark-cli base +record-upsert --base-token "<base_token>" --table-id "<suppliers_table_id>" \
--json '{"供应商名称":"深圳XX纺织厂","联系人":"张经理","联系电话":"13800138000","地址":"深圳市南山区XX路XX号","供应类别":"服装","合作状态":"合作中","备注":"主力供应商"}' \
--as user
5.2 Query supplier list
lark-cli base +record-list --base-token "<base_token>" --table-id "<suppliers_table_id>" \
--limit 200 --as user
5.3 Associate supplier with goods
lark-cli base +record-upsert --base-token "<base_token>" --table-id "<products_table_id>" \
--record-id "<products_record_id>" \
--json '{"供应商":["<suppliers_record_id>"]}' \
--as user
Associated field value format: the value is an array of record_ids of associated records
["recXXXX"]。
Intent → Command index
| Intent | Recommended command | Notes |
|---|---|---|
| Create an inventory management system | +base-create → 4 × +table-create → one by one +field-create → bidirectional association → lookup + formula |
Execute in the order of Step 1 |
| Add product | +record-upsert → products table |
|
| Modify product | +record-list → +record-upsert → products table |
First look up record_id |
| Delete product | +record-delete → products table |
With --yes |
| Stock in | +record-upsert → stock_in table |
Associated fields use an array of record_ids |
| Stock out | First verify inventory → +record-upsert → stock_out table |
Verification is required |
| Check inventory | +record-list → products table |
AI filtering/aggregation |
| Check stock-in records | +record-list → stock_in table |
|
| Check stock-out records | +record-list → stock_out table |
|
| Low stock alert | +record-list → products table → AI filtering |
|
| Send alert notification | im +messages-send |
chat_id required |
| Stock-in/stock-out summary | +data-query |
Aggregate only stored fields; put table-id in the DSL |
| Slow-moving analysis | +record-list → products table → AI calculation |
Use lookup field values |
| Generate report | docs +create |
Markdown template |
| Create dashboard | +dashboard-create → +dashboard-block-create |
|
| Add supplier | +record-upsert → suppliers table |
|
| Check suppliers | +record-list → suppliers table |
|
| Associate supplier | +record-upsert → products table |
Associated fields use an array of record_ids |
Common errors quick reference
| Error scenario | Cause | Solution |
|---|---|---|
+table-create --fields Rate limit 800004135 |
Creating multiple fields at once triggers rate limiting | First create an empty table, then use +field-create add fields one by one, with a 1.5-second interval |
| Formula field cross-table query returns the entire table's SUM | Unidirectional association cannot query in reverse; or the formula references the table name instead of the associated field | Associated fields must bidirectional: true; switch inventory calculation to a lookup + formula combination |
| Unidirectional association cannot be changed to bidirectional | API restriction unsafe_operation_blocked | Delete the old associated field and recreate a bidirectional association |
+data-query unknown flag --table-id |
This command does not support --table-id |
Put table-id in the --dsl of datasource.table.tableId in |
+data-query does not support aggregation for a certain field |
Formula/lookup/associated fields are not in the whitelist | Only aggregate stored fields |
+data-query alias Chinese garbled text |
CLI encoding issue | Use an English alias or have the agent map it itself |
| Failed to write associated field value | Format error | The associated field value must be a record_id array ["recXXX"] |
| Failed to write date field | Format error | Use a Unix millisecond timestamp (number), not a string |
| Inventory not updated after outbound | lookup formula calculation delay | Wait 3-5 seconds and query again |
+record-list Incomplete data |
Pagination not fully fetched | Use offset pagination, 200 per page |
| Insufficient permissions | scope not enabled | Refer to lark-shared to handle permission issues |
| Concurrency error 1254291 | list command concurrency | All +xxx-list executed serially |
| Message send failed | chat_id invalid | Use im +chat-list to confirm chat_id |
Permission table
| Command | Required scope |
|---|---|
base +base-create |
bitable:app |
base +table-create |
bitable:app |
base +field-create |
bitable:app |
base +field-list |
bitable:app:readonly |
base +record-list |
bitable:app:readonly |
base +record-upsert |
bitable:app |
base +record-delete |
bitable:app |
base +data-query |
bitable:app:readonly |
base +dashboard-create |
bitable:app |
im +messages-send |
im:message:send_as_bot |
docs +create |
docx:document:create |
Reference
../lark-shared/SKILL.md— Authentication, permissions (required reading)../lark-base/SKILL.md— Bitable atomic operations../lark-base/references/formula-field-guide.md— Formula field syntax (required reading before creating formula fields)../lark-base/references/lookup-field-guide.md— lookup field configuration rules (required reading before creating lookup fields)../lark-base/references/lark-base-shortcut-field-properties.md— Field property JSON specification../lark-base/references/lark-base-shortcut-record-value.md— Record value format specification../lark-base/references/lark-base-data-query.md— Aggregation analysis DSL../lark-base/references/dashboard-block-data-config.md— Dashboard Block configuration../lark-im/SKILL.md— Feishu message sending../lark-doc/SKILL.md— Feishu document creation