1

By default, a hyperlink type field in a SharePoint Online list looks like a regular field. It's not until you hover over the text that you actually see that it's a hyperlink.

I am trying to edit/format this field so it "pops" (i.e. underline and blue-color the font; shade the background, etc.).

I am able to achieve this by using a simple JSON script; however, it only works when the hyperlink is pointing to a web-based source (i.e. google.com). Some of my items have a hyperlink that direct the user to a file directory instead (i.e. //server_name/files/samplefile.docx). For these type of hyperlinks, the JSON script simply blanks the field.

Any help?

Here is the list:

List

Here are the values for item 1:

item1

And the values for item 2:

enter image description here

And there is the JSON script being applied to the "Test" field:

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "a",
  "txtContent": "@currentField.desc",
  "style": {
    "color": "red",
    "font-weight": "bold"
  },
  "attributes": {
    "target": "_blank",
    "href": "@currentField"
  }
}
  • You code seems fine. Just make sure you are passing complete document path like https:// tenant.sharepoint.com/sites/SPName/Shared%20Documents/Document.docx – Ganesh Sanap Mar 7 at 2:05
  • Thanks Ganesh. The document is NOT located in a sharepoint library, instead, it lives in a different server. – Dan Luna Mar 9 at 13:48
0

Your formatting is fine, but it appears that SharePoint Online is actively checking against href to make sure it begins with http, https, or mailto: within the JSON formatting.

You can't use column formatting to output links to protocols other than http://, https://, or mailto:.

This is a recommended feature to add to SharePoint on their uservoice platform. If you've found a work around, please post here. Even if you got the file protocol working, most modern browsers prevent those links from being opened, which would require an additional workaround.

If you were doing something similar with jslink previously, there is a guide for creating a SharePoint Framework Extension.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.