You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在SharePoint Online中用JSON条件格式基于两列禁用Close Job列?

SharePoint Close Job字段编辑权限控制方案

方案一:JSON条件格式(无需额外工具,快速生效)

这种方式依托SharePoint内置的列格式功能实现,无需依赖外部工具,完全匹配当前的简单权限控制需求。

操作步骤

  1. 打开目标SharePoint作业列表,进入列表设置
  2. 找到Close Job字段,点击进入字段设置页面
  3. 滚动至页面底部,点击格式列,切换到高级模式
  4. 替换默认JSON代码为以下内容(注意替换字段内部名称,见下方说明)

JSON代码示例

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": "=if(@currentField, 'CheckMark', 'Blank')"
      }
    },
    {
      "elmType": "input",
      "attributes": {
        "type": "checkbox",
        "checked": "@currentField"
      },
      "style": {
        "display": "=if(not(and(equals([$ReadytoBill], 'Invoiced'), not(empty([$CheckedIn])))), 'none', 'inline-block')"
      },
      "customRowAction": {
        "action": "setValue",
        "actionInput": {
          "CloseJob": "=not(@currentField)"
        }
      }
    },
    {
      "elmType": "span",
      "style": {
        "display": "=if(and(equals([$ReadytoBill], 'Invoiced'), not(empty([$CheckedIn]))), 'none', 'inline-block')",
        "padding": "0 4px"
      },
      "txtContent": "=if(@currentField, '已关闭', '未关闭')"
    }
  ],
  "disabled": "=not(and(equals([$ReadytoBill], 'Invoiced'), not(empty([$CheckedIn]))))"
}

关键说明

  • 替换代码中的ReadytoBill和CheckedIn为对应字段的内部名称(可在字段设置页面的URL中提取,比如URL参数Field=ReadytoBill)
  • 核心逻辑:仅当Ready to Bill值为Invoiced且Checked In不为空时,显示可编辑的复选框;否则仅展示文本状态,字段强制只读

方案二:Power Apps定制表单(灵活扩展,适配复杂场景)

如果后续需要添加更多逻辑(如弹窗提示、跨字段联动、数据校验),推荐使用Power Apps定制表单,控制精度更高。

操作步骤

  1. 在SharePoint列表页面,点击顶部集成 -> Power Apps -> 定制表单
  2. 在Power Apps编辑器中,找到Close Job对应的复选框控件(默认命名类似DataCardValue_CloseJob)
  3. 选中控件,在右侧属性面板找到DisplayMode属性,设置为以下公式:
If(
    And(
        DataCardValue_ReadytoBill.Selected.Value = "Invoiced",
        !IsBlank(DataCardValue_CheckedIn.Value)
    ),
    DisplayMode.Edit,
    DisplayMode.View
)
  1. 点击顶部保存,再点击发布表单,返回SharePoint列表即可生效

优势

  • 可添加悬浮提示,告知用户无法编辑的原因
  • 支持更复杂的多条件判断或关联数据交互
  • 用户体验更贴近定制化需求

Power Automate 删除流程补充

针对勾选Close Job后自动删除列表项的需求,配置流程如下:

  1. 新建Power Automate自动化流,选择当项目被创建或修改时作为触发条件,关联目标作业列表
  2. 添加条件动作:判断Close Job字段是否等于是
  3. 条件成立时,添加删除项目动作,选择当前列表和触发项的ID
  4. 保存并启用流即可

内容的提问来源于stack exchange,提问作者Dylan Lear

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 22:13:36