[英]SharePoint column formatting - Condition on text that could be upper or lower case?
I have a SharePoint list that has a column that is populated from a MS Form, the field that the user fills in is free text but they are required to enter a minimum of n/a into the box.我有一个 SharePoint 列表,其中有一列是从 MS 表单填充的,用户填写的字段是自由文本,但他们需要在框中输入至少 n/a。 The formatting I am trying to get to work will change the background of the field red if the contents are not n/a.如果内容不是 n/a,我尝试使用的格式将更改字段红色的背景。 As JSON is case sensitive I need to be able to check both n/a and N/A, I have found a reference to using (ToLowerCase) but my limited knowledge of JSON is not helping me here.由于 JSON 区分大小写,我需要能够检查 n/a 和 N/A,我找到了使用 (ToLowerCase) 的参考,但我对 JSON 的有限了解在这里对我没有帮助。
Current 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"
]
},
"",
""
]
}
}
}
]
}
Any assistance would be gratefully appreciated.任何帮助将不胜感激。
Thanks Rob谢谢罗伯
You could try below format.您可以尝试以下格式。
{
"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"
]
},
"",
""
]
}
}
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.