In a SharePoint List, I have a field of type 'Hyperlink or Picture' that has a URL like 'https://www.msn.com'
.
If the field is type text, I can do things like:
indexOf(@currentField, 'msn.com') > 0
If the field is type 'Hyperlink or Picture', this does not work.
What am I missing?
Update:
In the list view, it looks correct (note the correct icons):
When I add it to a page, the icons are not correct BUT the text is:
I just tested this on our SharePoint online site with hyperlink column in list. Here are the results:
JSON used:
{
"$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')"
}
Where Hyperlink
is the internal name of your SharePoint list column. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?
Output:
So, you should be able to check for any substring in "link" in hyperlink column using expression like:
indexOf([$Hyperlink], 'msn.com') > -1
If you want to check for any substring in "description/display" text of hyperlink column, use JSON like:
{
"$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')"
}
Output:
Note: indexOf
operator is case-sensitive