SharePoint列格式:JSON" @ currentField.lookupValue"在空白查找值

时间:2018-03-20 19:39:17

标签: json sharepoint

我有一个列表中的列表"状态 - 整体(查找)"哪种类型是"查找"。它从另一个列表中获取信息,并且只能有5个值:"红色"," Amber","绿色","灰色"或空值。

我将条件列格式应用于列"状态 - 整体(查找)"根据文章:https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

此处的JSON代码已粘贴到"列格式化"设置列表列:

{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"attributes": {
    "class": {
        "operator": "?",
        "operands": [
            {
                "operator": "==",
                "operands": [
                    {
                        "operator": "toString()",
                        "operands": [
                            "@currentField.lookupValue"
                        ]
                    },
                    "Green"
                ]
            },
            "sp-field-severity--good",
            {
                "operator": "?",
                "operands": [
                    {
                        "operator": "==",
                        "operands": [
                            {
                                "operator": "toString()",
                                "operands": [
                                    "@currentField.lookupValue"
                                ]
                            },
                            "Gray"                            ]
                    },
                    "sp-field-severity--low",
                    {
                        "operator": "?",
                        "operands": [
                            {
                                "operator": "==",
                                "operands": [
                                    {
                                        "operator": "toString()",
                                        "operands": [
                                            "@currentField.lookupValue"
                                        ]
                                    },
                                    "Amber"
                                ]
                            },
                            "sp-field-severity--warning",
                            {
                                "operator": "?",
                                "operands": [
                                    {
                                        "operator": "==",
                                        "operands": [
                                            {
                                                "operator": "toString()",
                                                "operands": [
                                                    "@currentField.lookupValue"
                                                ]
                                            },
                                            "Red"
                                        ]
                                    },
                                    "sp-field-severity--severeWarning",
                                    "sp-field-severity--blocked"
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
},
"children": [
    {
        "elmType": "span",
        "style": {
            "display": "inline-block",
            "padding": "0 4px"
        },
        "attributes": {
            "iconName": {
                "operator": "?",
                "operands": [
                    {
                        "operator": "==",
                        "operands": [
                            {
                                "operator": "toString()",
                                "operands": [
                                    "@currentField.lookupValue"
                                ]
                            },
                            "Green"
                        ]
                    },
                    "CheckMark",
                    {
                        "operator": "?",
                        "operands": [
                            {
                                "operator": "==",
                                "operands": [
                                    {
                                        "operator": "toString()",
                                        "operands": [
                                            "@currentField.lookupValue"
                                        ]
                                    },
                                    "Amber"
                                ]
                            },
                            "Forward",
                            {
                                "operator": "?",
                                "operands": [
                                    {
                                        "operator": "==",
                                        "operands": [
                                            {
                                                "operator": "toString()",
                                                "operands": [
                                                    "@currentField.lookupValue"
                                                ]
                                            },
                                            "Gray"
                                        ]
                                    },
                                    "Error",
                                    {
                                        "operator": "?",
                                        "operands": [
                                            {
                                                "operator": "==",
                                                "operands": [
                                                    {
                                                        "operator": "toString()",
                                                        "operands": [
                                                            "@currentField.lookupValue"
                                                        ]
                                                    },
                                                    "Red"
                                                ]
                                            },
                                            "Warning",
                                            "ErrorBadge"
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        }
    },
    {
        "elmType": "span",
        "txtContent": "@currentField.lookupValue"
    }
]}

此JSON适用于所有查找值,但显示以下错误的空白值除外:

  

(column-internal-name)。在数据对象上找不到.lookupValue。

enter image description here

有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:0)

我在这里得到了答复:https://github.com/SharePoint/sp-dev-column-formatting/issues/36

决议是改变" debugMode"来自' true'到' false'。现在条件格式正常,没有任何错误。