Skip to content

docs 示例的 type: 'lookup' 参数没有 picker target,渲染出来是「粘贴 ID」文本框 #821

Description

@yinlianghui

修 #813 时在同一个示例上顺带发现,超出该单的事实面(#813 讲的是多选投递通道,这条讲的是参数控件解析),按 Prime Directive #10 单独登记。

事实

docs/developers/code_examples.md 的 "Add An Action" 示例这样声明 Campaign 参数:

params: [
  { name: 'campaign', label: 'Campaign', type: 'lookup', required: true },
],

一个内联 lookup 参数必须带 reference: '<objectName>' 才能拿到 picker target。objectui packages/app-shell/src/utils/resolveActionParams.ts:295 把 param.reference 映射成解析后的 referenceTo,注释写得很直白:

Inline picker target (#3405). Without this an inline lookup param could never reach LookupField — paramToField() degrades a targetless picker to a raw record-id text input.

示例两者都没有(既无 reference,也无 field + objectOverride),所以照抄它的作者拿到的是一个要求用户手工粘贴记录 ID 的文本框,而不是记录选择器。没有报错、没有告警——参数照常提交,值也照常到达 body,只是没人填得出来。

本仓已经踩过一次

src/actions/lead.actions.ts 的 create_campaign 就是绕过这个坑落地的,注释原文(#813 前后均在):

Field-backed param: field + objectOverride make the console resolve the widget from crm_campaign_member.crm_campaign (a lookup → crm_campaign), rendering a RECORD PICKER. A bare { type:'lookup' } with no field can't resolve a target object and silently falls back to a paste-the-ID textbox.

也就是说:真实实现知道,示例不知道,而示例才是下一个作者(含 AI 作者)复制的那一份。

建议

示例参数二选一,加哪个都是一行:

  • 内联式:补 reference: 'crm_campaign';
  • field-backed:改成 { field: 'crm_campaign', objectOverride: 'crm_campaign_member', label: 'Campaign', required: true },与 lead.actions.ts 落地的写法一致。

倾向后者——它就是本仓真实跑着的那一版,示例与实现同形最省心。

为什么不折进 #813 的 PR

#813 的文件面确实覆盖这个文件,但两条是不同的事实:#813 是「多选选择集怎么到达 body」(_selectedIds 下划线),这条是「参数控件怎么解析出 picker」(reference / field)。#813 的 PR 只改了前者所需的部分,把这条单独留出来给 PM 定级。

严重度未自评(#4949:立单时的严重度判断两个方向都不可靠),交 PM triage。

Activity

  1. added
    bugSomething isn't working
    documentationImprovements or additions to documentation
    pm:queueReady for the PM dispatch loop
    pm:dispatchedDispatched to a dev agent by /pm-dispatch
    and removed
    pm:queueReady for the PM dispatch loop
    on Aug 5, 2026
  2. self-assigned this
    on Aug 6, 2026
  3. yinlianghui commented on Aug 6, 2026

    @yinlianghui
    CollaboratorAuthor

    [PM 认领 · R24 · 并单] session_01VHrPAGEgFDoHjphqYG4BMa · 与 #778 并单派发,分支 claude/issue-778-821-teaching-surface,裁定见 #778 认领评论(本单部分:走 field-backed 形,与 lead.actions.ts 同形)。PR 将以 Fixes #821 一并关闭本单。


    Generated by Claude Code

  4. yinlianghui commented on Aug 6, 2026

    @yinlianghui
    CollaboratorAuthor

    [PM 验收] 本单随并单 PR #889 一并验收通过(Fixes #821,与 #778 同 PR),已转 ready 并挂 auto-merge。示例参数改 field-backed 形(与 lead.actions.ts 同形),随动的 body key 改动(input.campaign→input.crm_campaign)按 spec 契约判为必然后果一并采纳。详细结论见 #778 评论区。


    Generated by Claude Code

  5. added and removed on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationpm:dispatchedDispatched to a dev agent by /pm-dispatchpriority:p2Medium: important, M3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions