: Seamlessly Open SharePoint Attachments from Power Apps Canvas App
✅ Overview
This guide walks you through every step needed to add an “Open Attachment” button inside your Canvas app gallery. It fetches the first attachment from SharePoint (list visio2) via Power Automate and opens it directly in the browser in preview mode.
๐ธ Step 1: Configure SharePoint for Attachments
-
Go to your
visio2SharePoint list. -
Select List Settings → Advanced Settings.
-
Ensure Attachments are set to Yes.
-
Save changes.
๐ Step 2: Create Power Automate Flow – GetVisio2AttachmentUrl
-
In Power Automate, click Create → Instant cloud flow.
-
Name it GetVisio2AttachmentUrl and select Power Apps (V2) trigger.
-
Click + Add an input, select Number, and rename it to itemID.
-
Get item Action:
-
Site: your SharePoint site
-
List: visio2
-
ID: choose itemID from trigger inputs
-
-
Get attachments Action:
-
Site: same as above
-
List: visio2
-
ID: still itemID
-
-
Compose Action:
-
Expression:
-
-
Respond to a Power App or flow Action:
-
Click + Add output → Text
-
Name it AttachmentUrl
-
Value:
Outputsfrom Compose
-
-
Click Save.
๐ฅ️ Step 3: Build the Canvas App
-
Open Power Apps Studio and add data source: SharePoint → visio2.
-
Insert a Vertical Gallery, set
Items = visio2. -
Within the gallery template, insert a Button and label it Open Attachment.
-
On the Action tab, click Power Automate and add your flow
GetVisio2AttachmentUrl.
✏️ Step 4: Add the Correct Button Formula
Paste this exact code into the button’s OnSelect property:
Explanation:
-
Value(ThisItem.ID): Ensures numeric type matches input. -
varResult: Holds the record returned by the flow. -
varResult.AttachmentUrl: Retrieves the URL stored in the record. -
Launch(...): Opens the file in the browser with?web=1to enable preview.
๐ Step 5: Save, Publish & Test
-
Save your app and click Publish.
-
Enter Preview Mode (F5).
-
Click Open Attachment on a gallery item — it should open the first attachment in a new browser tab!
Comments
Post a Comment