Using AND function in SharePoint
-
08-02-2021 - |
سؤال
I am trying to create relatively simple conditional column formatting in a SharePoint Online list.
This works (the conditions 1==1 and 2==2 are placeholders to simplify the example here):
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if(1==1, '#ff0000', '#ff00ff')"
}
}
But when I introduce an AND function, it doesn't work (no formatting occurs):
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if(AND(1==1, 2==2), '#ff0000', '#ff00ff')"
}
}
What am I doing wrong?
المحلول
You can use &&
for Anding conditions and ||
for Oring
This should work for you:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if(1==1 && 2==2, '#ff0000', '#ff00ff')"
}
}
لا تنتمي إلى sharepoint.stackexchange