1

In my last question SharePoint online problem with HTML link in the column, Ganesh Sanap figure out how put attachment to new column with JSON format to make them open without download needs.

My first question is, if is possible make that URL shorter in the JSON format:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
  "display": "flex",
  "flex-direction": "column",
  "align-items": "flex-start",
  "padding": "11px 0",
  "min-height": "0"
  },
  "children": [
      {
      "elmType": "a",
      "forEach": "item in split(@currentField,'|')",
      "attributes": {
          "href": "[$item]",
          "target": "_blank"
       },
       "txtContent": "[$item]"
      }
    ]
  } 

for example change https://company.sharepoint.com/list/1.pdf to 1.pdf with working hyperlink.

second question is, how show this collumn in Customize Form in PowerApp to make it visible with hyperlink.

When i put in Form Source and Add DataCard I see the links but only as text. HyperLink not working.

Many thanks for any advice.

1 Answer 1

2

You can use JSON formatting like below to show only the file names instead of full URL:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "display": "flex",
    "flex-direction": "column",
    "align-items": "flex-start",
    "padding": "11px 0",
    "min-height": "0"
  },
  "children": [
    {
      "elmType": "a",
      "forEach": "item in split(@currentField,'|')",
      "attributes": {
        "href": "[$item]",
        "target": "_blank"
      },
      "txtContent": "=substring([$item], lastIndexOf([$item], '/') + 1, indexOf([$item] + '^', '^'))"
    }
  ]
}

Output:

enter image description here


For showing the links on Power apps customized list form, you have to use the HTMLText control and apply similar logic as used in JSON formatting to split the URLs and then generate hyperlinks using a tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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