0

I have nearly solved my problem how to open Attachment directly in web Browser from SharePoint list without downloading the file.

I have only problem with more then one Attachment.

My Power automate flow:

1) When an item is created

2) Get attachments

3) Apply to each

3.1) Compose @items('Apply_to_each')?['AboluteUri']

4) Compose 2 @join(outputs('Compose'),' | ')

5) Update item @outputs('Compose_2')

result:

https://sharepoint/pdf.1 | https://sharepoint/pdf.2

SharePoint list column is Single line of text with this JSON:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "href": "@currentField",
    "target": "_blank"
 },
  "txtContent": "@currentField"
 }

When I have only one attachment, works perfectly. Problem is if i have more then one. Two https links are merged to single one.

Do you have any idea how to separate those links as two or more single links? Maybe change something in the flow.

Many thanks for any advice.

1 Answer 1

1

First of all, use Multiple lines of text (plain text) column for storing attachment file URLs instead of Single line of text column.

Then use below JSON formatting for your column:

{
  "$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]"
    }
  ]
}

Before applying JSON:

enter image description here

After applying JSON:

enter image description here

4
  • 1
    you are the best, works ! thank you
    – Novice
    Dec 21, 2022 at 13:30
  • Great, glad it worked for you! Dec 21, 2022 at 13:31
  • is there any option in JSON format to make link shorter ? for example pdf.1 and pdf.2 ?
    – Novice
    Dec 22, 2022 at 8:27
  • Can you please Ask a new question with more details about your requirements? I will try to answer with explanation specific to your new question. Dec 22, 2022 at 8:29

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.