json SharePoint列表:字段类型为“超链接或图片”时如何使用indexOf(@currentField,'target')

dly7yett  于 5个月前  发布在  其他
关注(0)|答案(2)|浏览(49)

在SharePoint列表中,我有一个类型为“超链接或图片”的字段,其URL类似于'https://www.msn.com'
如果字段是类型文本,我可以做这样的事情:

indexOf(@currentField, 'msn.com') > 0

字符串
如果字段类型为“超链接或图片”,则此操作无效。
我错过了什么?
更新:在列表视图中,它看起来是正确的(注意正确的图标):

当我将其添加到页面时,图标不正确,但文本是:

2jcobegt

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?

输出

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运算符区分大小写

rhfm7lfc

rhfm7lfc2#

发现一个小错别字的逻辑,我相信这个问题是关闭的。

相关问题