pnp / List-Formatting

List Formatting Samples for use in SharePoint and Microsoft Lists
https://pnp.github.io/List-Formatting/
MIT License
1.74k stars 833 forks source link

I have a question about generic-hyperlink-valuesAST.json #603

Closed pettaa123 closed 1 year ago

pettaa123 commented 1 year ago

Sample generic-hyperlink-valuesAST.json

I want to extract the link from a different field named "File_Path" in order to use it as href using this code:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "a",
      "txtContent": "some static name",
      "attributes": {
        "href": "=[$File_Path]",
        "target": "_blank"
      }
    }
  ]
}

The content of File_Path field is: file://G:/SomeFolder/SomeSubFolder But this gives me a link that looks like:

https://SomeLinkToTeamsite/=[$FilePath]

Removing the equal lets the "some static name" disappear

Question

How can I insert a local link in the style: file://G:/SomeFolder/? I am aware that only IE would open that one.

Fedes365 commented 1 year ago

@pettaa123 Tried with your code and it seems that local paths are not supported. A similar use case has been described here: https://sharepoint.stackexchange.com/questions/277321/formatting-hyperlink-type-field-with-file-directory-path