SuperAPI AI Directory

wecomcli-manage-smartsheet-data

Office & productivity

View repository

Updated 10-16 09:45

About this skill

WeCom smart sheet data management

wecom-cli is a command-line program provided by WeCom. All operations are completed by executing the wecom-cli command.

Manage records (row data) in a smart sheet. All interfaces support locating documents via either docid or url .

CLI invocation method

Invoked via wecom-cli , with category doc:

wecom-cli doc <tool_name> '<json_params>'

Return format description

All interfaces return a JSON object containing the following common fields:

Field Type Description
errcode integer Return code,0 indicates success, non- 0 indicates failure
errmsg string Error message, when successful it is "ok"

When errcode is not 0 , it indicates the interface call failed and can be retried once; if it still fails, display errcode and errmsg to the user.

smartsheet_get_records

Query all records in a sub-sheet.

  • Via sheetid:
wecom-cli doc smartsheet_get_records '{"docid": "DOCID", "sheet_id": "SHEETID"}'
  • Or via URL:
wecom-cli doc smartsheet_get_records '{"url": "https://doc.weixin.qq.com/smartsheet/xxx", "sheet_id": "SHEETID"}'

See API details。

smartsheet_add_records

Add one or more rows of records; it is recommended to keep it within 500 rows at a time.

Before callingyou must first understand the field types of the target sheet (via smartsheet_get_fields), with focus on field_type. For single-select/multi-select (Option) fields, pay attention to matching the id。

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

Update one or more rows of records; it is recommended to keep it within 500 rows at a time. record_id must be provided (obtained via smartsheet_get_records ). Supports specifying via key_type that the key of values uses the field title or field ID:

  • CELL_VALUE_KEY_TYPE_FIELD_TITLE: key is the field title
  • CELL_VALUE_KEY_TYPE_FIELD_ID: key is the field ID
wecom-cli doc smartsheet_update_records '{"docid": "DOCID", "sheet_id": "SHEETID", "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", "records": [{"record_id": "RECORDID", "values": {"任务名称": [{"type": "text", "text": "更新后的内容"}]}}]}'

Note: The creation time, last edit time, creator, and last editor fields cannot be updated.

smartsheet_delete_records

Delete one or more rows of records; it must be within 500 rows at a time.The operation is irreversible. record_id is obtained via smartsheet_get_records .

wecom-cli doc smartsheet_delete_records '{"docid": "DOCID", "sheet_id": "SHEETID", "record_ids": ["RECORDID1", "RECORDID2"]}'

Typical workflow

  1. Read data →
wecom-cli doc smartsheet_get_records '{"docid":"DOCID","sheet_id":"SHEETID"}'
  1. Write data → first smartsheet_get_fields understand column types → if member (USER) fields are involved, first use wecomcli-lookup-contact 's get_userlist to find the person's userid → smartsheet_add_records write
  2. Update data → first smartsheet_get_records obtain record_id → if member (USER) fields are involved, first use wecomcli-lookup-contact 's get_userlist to find the person's userid → smartsheet_update_records update
  3. Delete data → first smartsheet_get_records confirm record_id → smartsheet_delete_records delete

Note: Member (USER) type fields require filling in user_id, and the name cannot be used directly. You must first use wecomcli-lookup-contact skill's get_userlist interface to find the corresponding person by name userid then use it.