json - SharePoint 列格式 - 可能是大写或小写文本的条件?
问题描述
我有一个 SharePoint 列表,其中有一列是从 MS 表单填充的,用户填写的字段是自由文本,但他们需要在框中输入最少的 n/a。如果内容不是 n/a,我尝试使用的格式将更改字段红色的背景。由于 JSON 区分大小写,我需要能够同时检查 n/a 和 N/A,我找到了使用 (ToLowerCase) 的参考,但我对 JSON 的有限知识在这里对我没有帮助。
当前 JSON
{
"elmType": "div",
"style": {
"box-sizing": "border-box",
"padding": "0 2px"
},
"attributes": {
"class": {
"operator": ":",
"operands": [
{
"operator": "!=",
"operands": [
"@currentField",
"n/a"
]
},
"sp-css-backgroundColor-errorBackground50",
""
]
}
},
"children": [
{
"elmType": "span",
"style": {
"line-height": "16px",
"height": "14px"
},
"attributes": {
"iconName": {
"operator": ":",
"operands": [
{
"operator": "!=",
"operands": [
"@currentField",
"n/a"
]
]
},
"",
""
]
}
}
},
{
"elmType": "span",
"style": {
"overflow": "hidden",
"text-overflow": "ellipsis",
"padding": "0 3px"
},
"txtContent": "@currentField",
"attributes": {
"class": {
"operator": ":",
"operands": [
{
"operator": "!=",
"operands": [
"@currentField",
"n/a"
]
},
"",
""
]
}
}
}
]
}
任何帮助将不胜感激。
谢谢罗伯
解决方案
您可以尝试以下格式。
{
"elmType": "div",
"style": {
"box-sizing": "border-box",
"padding": "0 2px"
},
"attributes": {
"class": "=if(toLowerCase(@currentField) != 'n/a', 'sp-css-backgroundColor-errorBackground50', '')"
},
"children": [
{
"elmType": "span",
"style": {
"line-height": "16px",
"height": "14px"
},
"attributes": {
"iconName": {
"operator": ":",
"operands": [
{
"operator": "!=",
"operands": [
"@currentField",
"n/a"
]
},
"",
""
]
}
}
},
{
"elmType": "span",
"style": {
"overflow": "hidden",
"text-overflow": "ellipsis",
"padding": "0 3px"
},
"txtContent": "@currentField",
"attributes": {
"class": {
"operator": ":",
"operands": [
{
"operator": "!=",
"operands": [
"@currentField",
"n/a"
]
},
"",
""
]
}
}
}
]
}
推荐阅读
- c# - 使用静态机密对 Twitter 机器人进行身份验证?
- java - 我怎样才能让我的打印语句在打印平均分数和相关字母等级的地方工作?
- algorithm - 为什么在 Edmonds Karp 算法中使用 BFS 以使其与 Ford Fulkerson 更好?
- postgresql - Crystal Reports SQL 命令的 Postgresql 参数化查询
- hyperledger-fabric - Hyperledger Fabric:为什么 cryptogen 不生成所有必要的加密材料来注册新用户?
- python - 为什么 __dict__ 不包含类成员,除非使用正确的初始化?
- r - rlang::fn_fmls() 可以嵌套吗?
- datatables - 数据表:缺少页面元素(排序、搜索、下一个...)
- php - 为什么 Laravel 找不到使用“/”的控制器?
- google-app-engine - kubectl 命令找不到命名空间值