在SharePoint列表中,我有一个类型为“超链接或图片”的字段,其URL类似于'https://www.msn.com'。如果字段是类型文本,我可以做这样的事情:
'https://www.msn.com'
indexOf(@currentField, 'msn.com') > 0
字符串如果字段类型为“超链接或图片”,则此操作无效。我错过了什么?更新:在列表视图中,它看起来是正确的(注意正确的图标):
当我将其添加到页面时,图标不正确,但文本是:
2jcobegt1#
我刚刚在我们的SharePoint在线网站上测试了这个,列表中有超链接列。下面是结果:JSON使用:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=if(indexOf([$Hyperlink], 'msn.com') > -1, 'Found MSN', 'Not found')" }
字符串其中Hyperlink是SharePoint列表列的内部名称。您可以通过阅读本文获取SharePoint列表列的内部名称:How to find the Internal name of columns in SharePoint Online?
Hyperlink
输出:
x1c 0d1x的数据因此,您应该能够使用以下表达式检查超链接列中“link”中的任何子字符串:
indexOf([$Hyperlink], 'msn.com') > -1
型如果你想检查超链接列的“描述/显示”文本中的任何子字符串,请使用JSON,如:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=if(indexOf([$Hyperlink.desc], 'MSN') > -1, 'Found MSN', 'Not found')" }
型
的
注意:indexOf运算符区分大小写
indexOf
rhfm7lfc2#
发现一个小错别字的逻辑,我相信这个问题是关闭的。
2条答案
按热度按时间2jcobegt1#
我刚刚在我们的SharePoint在线网站上测试了这个,列表中有超链接列。下面是结果:
JSON使用:
字符串
其中
Hyperlink
是SharePoint列表列的内部名称。您可以通过阅读本文获取SharePoint列表列的内部名称:How to find the Internal name of columns in SharePoint Online?输出:
x1c 0d1x的数据
因此,您应该能够使用以下表达式检查超链接列中“link”中的任何子字符串:
型
如果你想检查超链接列的“描述/显示”文本中的任何子字符串,请使用JSON,如:
型
输出:
的
注意:
indexOf
运算符区分大小写rhfm7lfc2#
发现一个小错别字的逻辑,我相信这个问题是关闭的。