如何实现SharePoint列表按钮更新当前日期时间字段?
- 问题根源:你用的"Now ()"是错误写法,SharePoint列格式化的
setValue动作里,获取当前日期时间必须用内置的@now变量,不需要加引号、空格和括号。 - 列类型无需调整:
RunbookLastUpdated保持DateTime类型即可,不用修改。
修正后的列格式化代码:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "button", "txtContent": "Update Runbook", "customRowAction": { "action": "setValue", "actionInput": { "UpdatedBy": "@me", "RunbookLastUpdated": "@now" } } }
补充说明:@now返回的是UTC时间,SharePoint会自动根据站点时区转换显示,无需额外处理。
内容的提问来源于stack exchange,提问作者Justin E
相关产品推荐
相关产品推荐

