IT/PowerApps

PowerApps Direct interface to Document Library

Last72 2020. 9. 25. 17:24

Goal: A button in PowerApps to attach files to SharePoint Document Library

 

Prerequesit:

- An SharePoint site with Document library and a list

- An canvas app connected to that SharePoint site

 

 

Procedure

1. Gallery with files

1.1. Create a gallery and change followings

Gallery1.Items:

Documents // SharePoint Document Library

 

1.2. Put 2 lables and a icon in gallery and change followings

Label1.Text:

ThisItem.Name

Label1.Fill:

LightGray

Label1.OnSelect:

Launch(ThisItem.'Link to item')

Label2.Text:

ThisItem.Author.DisplayName

Icon1.OnSelect:

Remove(Documents, ThisItem)

 

 

2. Upload files

2.1. Create flow

Name: [DEV] Upload File

Type: Instant

Trigger: PowerApps

 

2.1.1. Add first action

Action: Data Operation - Parse JSON

Rename to: Payload

Content: Dynamic content - PowerApps - Ask in PowerApps

Click Generate from sample and put: {"FileName":"", "FileContent":""}

 

2.1.2. Add second action

Action: SharePoint - Create File

Site Address: Your SharePoint site address (i.e. woongdev.sharepoint.com/sites/UngyiTech)

Folder Path: Your Document Library (i.e. /Shared Documents)

File Name: Dynamic content - Payload - FileName

File Content : Expression - dataUriToBinary(body('Payload')?['FileContent'])

 

2.2 Get Attachment control

2.2.1. In PowerApps, Insert - Forms - Edit and change followings

DataSource:

'Dummy List' // Any SharePoint list

Click Edit fields - add field - Attachments

Copy the attachment control and paste it outside of the form.

Empty fields with errors to fix it.

Rename to: attDocument

 

2.3 Connect the flow to PowerApps

Create a button and click Action - PowerAuotmate - [DEV] Upload File

Delete the button afterwards

 

2.4 Create an image control and change followings:

Image:

First(attDocument.Attachments).Value

Visible:

false

 

2.5 Link attachment control to flow

Change attDocument property as follows

attDocument.OnAddFile:

'[DEV]UploadFile'.Run(JSON({FileName:First(Self.Attachments).Name, FileContent:Image1.Image}, JSONFormat.IncludeBinaryData)); Reset(Self);

 

2.6 Add Refresh button.

Create a button and set property as follows

Button2.OnSelect:

Refresh(Documents) // SharePoint Document Library

 

Done

 

Youtube link: # - https://youtu.be/L18XoCSOWYk