wecomcli-manage-smartsheet-data

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

企业微信智能表格数据管理

WeCom Smart Table Data Management

wecom-cli
是企业微信提供的命令行程序,所有操作通过执行
wecom-cli
命令完成。
管理智能表格中的记录(行数据)。所有接口支持通过
docid
url
二选一定位文档。
wecom-cli
is a command line program provided by WeCom, and all operations are completed by executing the
wecom-cli
command.
Manage records (row data) in smart tables. All interfaces support locating documents by either
docid
or
url
.

CLI 调用方式

CLI Calling Method

通过
wecom-cli
调用,品类为
doc
bash
wecom-cli doc <tool_name> '<json_params>'
Called via
wecom-cli
, with the category as
doc
:
bash
wecom-cli doc <tool_name> '<json_params>'

返回格式说明

Return Format Description

所有接口返回 JSON 对象,包含以下公共字段:
字段类型说明
errcode
integer返回码,
0
表示成功,非
0
表示失败
errmsg
string错误信息,成功时为
"ok"
errcode
不为
0
时,说明接口调用失败,可重试 1 次;若仍失败,将
errcode
errmsg
展示给用户。
All interfaces return JSON objects, including the following public fields:
FieldTypeDescription
errcode
integerReturn code,
0
means success, non-
0
means failure
errmsg
stringError message, which is
"ok"
when the call is successful
When
errcode
is not
0
, it means the interface call failed, you can retry once; if it still fails, display the
errcode
and
errmsg
to the user.

smartsheet_get_records

smartsheet_get_records

查询子表全部记录。
bash
wecom-cli doc smartsheet_get_records '{"docid": "DOCID", "sheet_id": "SHEETID"}'
  • 或通过 URL:
bash
wecom-cli doc smartsheet_get_records '{"url": "https://doc.weixin.qq.com/smartsheet/xxx", "sheet_id": "SHEETID"}'
参见 API 详情
Query all records of the sub-table.
bash
wecom-cli doc smartsheet_get_records '{"docid": "DOCID", "sheet_id": "SHEETID"}'
  • Or via URL:
bash
wecom-cli doc smartsheet_get_records '{"url": "https://doc.weixin.qq.com/smartsheet/xxx", "sheet_id": "SHEETID"}'
See API Details.

smartsheet_add_records

smartsheet_add_records

添加一行或多行记录,单次建议 500 行内。
调用前必须先了解目标表的字段类型(通过
smartsheet_get_fields
)。
bash
wecom-cli doc smartsheet_add_records '{"docid": "DOCID", "sheet_id": "SHEETID", "records": [{"values": {"任务名称": [{"type": "text", "text": "完成需求文档"}], "优先级": [{"text": "高"}]}}]}'
各字段类型的值格式参见 单元格值格式参考
Add one or more rows of records, it is recommended to add no more than 500 rows at a time.
Before calling, you must first understand the field types of the target table (via
smartsheet_get_fields
).
bash
wecom-cli doc smartsheet_add_records '{"docid": "DOCID", "sheet_id": "SHEETID", "records": [{"values": {"任务名称": [{"type": "text", "text": "完成需求文档"}], "优先级": [{"text": "高"}]}}]}'
For the value format of each field type, see Cell Value Format Reference.

smartsheet_update_records

smartsheet_update_records

更新一行或多行记录,单次必须在 500 行内。需提供 record_id(通过
smartsheet_get_records
获取)。
bash
wecom-cli doc smartsheet_update_records '{"docid": "DOCID", "sheet_id": "SHEETID", "records": [{"record_id": "RECORDID", "values": {"任务名称": [{"type": "text", "text": "更新后的内容"}]}}]}'
注意:创建时间、最后编辑时间、创建人、最后编辑人字段不可更新。
Update one or more rows of records, no more than 500 rows at a time. You need to provide the record_id (obtained via
smartsheet_get_records
).
bash
wecom-cli doc smartsheet_update_records '{"docid": "DOCID", "sheet_id": "SHEETID", "records": [{"record_id": "RECORDID", "values": {"任务名称": [{"type": "text", "text": "更新后的内容"}]}}]}'
Note: Fields such as creation time, last edit time, creator, and last editor cannot be updated.

smartsheet_delete_records

smartsheet_delete_records

删除一行或多行记录,单次必须在 500 行内。操作不可逆。record_id 通过
smartsheet_get_records
获取。
bash
wecom-cli doc smartsheet_delete_records '{"docid": "DOCID", "sheet_id": "SHEETID", "record_ids": ["RECORDID1", "RECORDID2"]}'
Delete one or more rows of records, no more than 500 rows at a time. The operation is irreversible. The record_id is obtained via
smartsheet_get_records
.
bash
wecom-cli doc smartsheet_delete_records '{"docid": "DOCID", "sheet_id": "SHEETID", "record_ids": ["RECORDID1", "RECORDID2"]}'

典型工作流

Typical Workflow

  1. 读取数据
bash
wecom-cli doc smartsheet_get_records '{"docid":"DOCID","sheet_id":"SHEETID"}'
  1. 写入数据 → 先
    smartsheet_get_fields
    了解列类型 → 若涉及成员(USER)字段,先通过
    wecomcli-lookup-contact
    get_userlist
    查找人员 userid →
    smartsheet_add_records
    写入
  2. 更新数据 → 先
    smartsheet_get_records
    获取 record_id → 若涉及成员(USER)字段,先通过
    wecomcli-lookup-contact
    get_userlist
    查找人员 userid →
    smartsheet_update_records
    更新
  3. 删除数据 → 先
    smartsheet_get_records
    确认 record_id →
    smartsheet_delete_records
    删除
注意:成员(USER)类型字段需要填写
user_id
,不能直接使用姓名。必须先通过
wecomcli-lookup-contact
技能的
get_userlist
接口按姓名查找到对应的
userid
后再使用。
  1. Read data
bash
wecom-cli doc smartsheet_get_records '{"docid":"DOCID","sheet_id":"SHEETID"}'
  1. Write data → First use
    smartsheet_get_fields
    to understand the column types → If member (USER) fields are involved, first find the user's userid via the
    get_userlist
    interface of
    wecomcli-lookup-contact
    → Write data via
    smartsheet_add_records
  2. Update data → First obtain record_id via
    smartsheet_get_records
    → If member (USER) fields are involved, first find the user's userid via the
    get_userlist
    interface of
    wecomcli-lookup-contact
    → Update data via
    smartsheet_update_records
  3. Delete data → First confirm the record_id via
    smartsheet_get_records
    → Delete data via
    smartsheet_delete_records
Note: Member (USER) type fields require filling in
user_id
, and you cannot directly use the name. You must first find the corresponding
userid
by name through the
get_userlist
interface of the
wecomcli-lookup-contact
Skill before using it.