team-ownership

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Prereq: read
bulk-operations/SKILL.md
first. JSONL piping, pagination, dry-run/digest/confirm, and
hubspot history
recovery live there. Reshape patterns live in
bulk-operations/resources/json-patterns.md
.
hubspot_owner_id
is a string field on
contacts
,
companies
,
deals
, and
tickets
. Owners are CRM users —
hubspot owners list
returns them; there is no
teams
object, so team-level views are client-side groupings by
hubspot_owner_id
.
前置要求:请先阅读
bulk-operations/SKILL.md
。JSONL管道传输、分页、试运行/摘要/确认以及
hubspot history
恢复的相关内容均在该文档中。数据重塑模式可查看
bulk-operations/resources/json-patterns.md
hubspot_owner_id
contacts
companies
deals
tickets
对象中的字符串字段。所有者即CRM用户——可通过
hubspot owners list
命令查看;系统中没有
teams
对象,因此团队级视图是通过
hubspot_owner_id
在客户端进行分组实现的。

1. Resolve email → owner ID

1. 将邮箱转换为所有者ID

Never hardcode IDs — they are portal-specific. Resolve, then cache:
bash
FROM_ID=$(hubspot owners list | jq -r 'select(.email=="sarah@company.com") | .id')
TO_ID=$(hubspot owners list | jq -r 'select(.email=="mike@company.com")  | .id')
切勿硬编码ID——ID是特定于门户的。请先解析并缓存:
bash
FROM_ID=$(hubspot owners list | jq -r 'select(.email=="sarah@company.com") | .id')
TO_ID=$(hubspot owners list | jq -r 'select(.email=="mike@company.com")  | .id')

2. Find records for an owner

2. 查找某所有者的记录

Same filter across all four object types. Add object-specific
--properties
for context. Unowned records use the
!property
form.
bash
hubspot objects search --type contacts  --filter "hubspot_owner_id=$FROM_ID" --properties email,firstname,lifecyclestage
hubspot objects search --type companies --filter "hubspot_owner_id=$FROM_ID" --properties name,domain
hubspot objects search --type deals     --filter "hubspot_owner_id=$FROM_ID" --properties dealname,dealstage,amount
hubspot objects search --type tickets   --filter "hubspot_owner_id=$FROM_ID" --properties subject,hs_pipeline_stage
所有四种对象类型使用相同的筛选规则。可添加对象特定的
--properties
参数以获取上下文信息。无所有者的记录使用
!property
格式筛选。
bash
hubspot objects search --type contacts  --filter "hubspot_owner_id=$FROM_ID" --properties email,firstname,lifecyclestage
hubspot objects search --type companies --filter "hubspot_owner_id=$FROM_ID" --properties name,domain
hubspot objects search --type deals     --filter "hubspot_owner_id=$FROM_ID" --properties dealname,dealstage,amount
hubspot objects search --type tickets   --filter "hubspot_owner_id=$FROM_ID" --properties subject,hs_pipeline_stage

Records with no owner at all

无所有者的记录

hubspot objects search --type deals --filter "!hubspot_owner_id" --properties dealname,amount

>100 hits — page with the `--after` loop from `bulk-operations`. Counting only: pipe to `wc -l`.
hubspot objects search --type deals --filter "!hubspot_owner_id" --properties dealname,amount

>若结果超过100条,请使用`bulk-operations`中的`--after`循环进行分页。仅统计数量的话,可将结果管道传输至`wc -l`。

3. Bulk reassign — search → update

3. 批量重新分配——搜索→更新

Reshape each search row into
{id, properties:{hubspot_owner_id}}
and pipe to
objects update
. Always dry-run first; for >100 rows the dry-run emits a digest +
apply_command_hint
— re-run with
--digest
/
--confirm
(see
bulk-operations/SKILL.md
§ "Safe destructive workflow").
bash
undefined
将每条搜索结果重塑为
{id, properties:{hubspot_owner_id}}
格式,并管道传输至
objects update
命令。请始终先执行试运行;若结果超过100条,试运行会生成摘要及
apply_command_hint
——请按照
bulk-operations/SKILL.md
中“安全破坏性工作流”章节的说明,添加
--digest
/
--confirm
参数重新运行。
bash
undefined

Dry-run

试运行

hubspot objects search --type contacts --filter "hubspot_owner_id=$FROM_ID"
| jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}'
| hubspot objects update --type contacts --dry-run
hubspot objects search --type contacts --filter "hubspot_owner_id=$FROM_ID"
| jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}'
| hubspot objects update --type contacts --dry-run

Execute — ≤100: drop --dry-run. >100: append --digest <hash> --confirm <count>.

执行——≤100条:移除--dry-run参数。>100条:添加--digest <哈希值> --confirm <数量>参数。

hubspot objects search --type contacts --filter "hubspot_owner_id=$FROM_ID"
| jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}'
| hubspot objects update --type contacts

Single-record assignment — no stdin, no jq:

```bash
hubspot objects update --type contacts 12345 --property hubspot_owner_id=$TO_ID
hubspot objects search --type contacts --filter "hubspot_owner_id=$FROM_ID"
| jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}'
| hubspot objects update --type contacts

单条记录分配——无需标准输入,无需jq:

```bash
hubspot objects update --type contacts 12345 --property hubspot_owner_id=$TO_ID

4. Rep-leaves workflow

4. 销售代表离职工作流

Loop over the four object types the rep touches:
bash
FROM_ID=$(hubspot owners list | jq -r 'select(.email=="leaving@company.com")    | .id')
TO_ID=$(hubspot  owners list | jq -r 'select(.email=="taking-over@company.com") | .id')

for type in contacts companies deals tickets; do
  echo "── $type ──"
  hubspot objects search --type "$type" --filter "hubspot_owner_id=$FROM_ID" \
  | jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}' \
  | hubspot objects update --type "$type" --dry-run
done
Review each digest line, then re-run without
--dry-run
(adding
--digest
/
--confirm
per type when escalated). Mis-reassigned?
hubspot history --since 1h
lists the affected IDs.
遍历该销售代表负责的四种对象类型:
bash
FROM_ID=$(hubspot owners list | jq -r 'select(.email=="leaving@company.com")    | .id')
TO_ID=$(hubspot  owners list | jq -r 'select(.email=="taking-over@company.com") | .id')

for type in contacts companies deals tickets; do
  echo "── $type ──"
  hubspot objects search --type "$type" --filter "hubspot_owner_id=$FROM_ID" \
  | jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}' \
  | hubspot objects update --type "$type" --dry-run
done
查看每条摘要信息,然后移除
--dry-run
参数重新运行(当结果数量较多时,需按对象类型添加
--digest
/
--confirm
参数)。分配错误?可使用
hubspot history --since 1h
命令查看受影响的ID。

5. Team-level views (client-side grouping)

5. 团队级视图(客户端分组)

Group records by
hubspot_owner_id
, join to
owners list
for human-readable emails:
bash
hubspot objects search --type deals --filter "dealstage!=closedwon AND dealstage!=closedlost" \
  --properties hubspot_owner_id --format json \
| jq '.data | group_by(.properties.hubspot_owner_id)
       | map({owner_id: .[0].properties.hubspot_owner_id, count: length})' \
> /tmp/by-owner.json

hubspot owners list \
| jq --slurpfile by /tmp/by-owner.json -r \
     '. as $o | $by[0][] | select(.owner_id==$o.id) | "\($o.email)\t\(.count)"'
hubspot_owner_id
对记录进行分组,关联
owners list
结果以获取易读的邮箱地址:
bash
hubspot objects search --type deals --filter "dealstage!=closedwon AND dealstage!=closedlost" \
  --properties hubspot_owner_id --format json \
| jq '.data | group_by(.properties.hubspot_owner_id)
       | map({owner_id: .[0].properties.hubspot_owner_id, count: length})' \
> /tmp/by-owner.json

hubspot owners list \
| jq --slurpfile by /tmp/by-owner.json -r \
     '. as $o | $by[0][] | select(.owner_id==$o.id) | "\($o.email)\t\(.count)"'