首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SharePoint列格式: JSON "@currentField.lookupValue“在出现空白查找值时抛出错误

SharePoint列格式: JSON "@currentField.lookupValue“在出现空白查找值时抛出错误
EN

Stack Overflow用户
提问于 2018-03-20 19:39:17
回答 1查看 5.2K关注 0票数 0

我有一个SharePoint列表,列有"Status -全局(查找)“,它的类型是”查找“。它从另一个列表中获取信息,只有5个值:“红色”、“琥珀”、“绿色”、“灰色”或空白值。

根据本文:https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting,我将条件列格式应用于列“状态-总体(查找)”。

下面是JSON代码,它被粘贴到列表列的“列格式”设置中:

代码语言:javascript
复制
{
"$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对所有查找值都很好:

(列内部名称)在数据对象上找不到.lookupValue。

有办法解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-23 11:24:25

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

解决方案是将"debugMode“从”true“改为”false“。现在,条件格式工作正常,没有任何错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49392815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档