skip to Main Content

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):
enter image description here

When I add it to a page, the icons are not correct BUT the text is:
enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    found a small typo in the logic, I believe this issue is closed.


  2. 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:

    enter image description here

    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:

    enter image description here

    Note: indexOf operator is case-sensitive

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search