在 SharePoint 列表中,我有一个“超链接或图片”类型的字段,其 URL 类似于“https://www.msn.com”。
如果该字段是文本类型,我可以做类似的事情
indexOf(@currentField, 'msn.com') > 0
如果字段类型为“超链接或图片”,则此操作不起作用。
我错过了什么?
我刚刚在我们的 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 列表列的内部名称:如何在 SharePoint Online 中查找列的内部名称?
输出:
因此,您应该能够使用以下表达式检查超链接列中“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
运算符区分大小写