Hi all,
I'm working on an app in PowerApps that requires file management with SharePoint through Power Automate. The process I have in place involves a user attaching multiple files within PowerApps, which then triggers a flow to upload these files to SharePoint.
Here's where I'm encountering a challenge:
- The original flow was designed to create a new folder in SharePoint for each file uploaded. This resulted in multiple folders being created when multiple files were attached - one folder per file, which isn't what I need.
- To address this, I created a separate flow that runs first to create a single new folder in SharePoint. This flow then uses the 'Respond to a PowerApp or flow' action to send back the folder path (named 'foldername') to PowerApps.
- With this setup, I'm unsure about the additional input I need to include in the PowerApps trigger for the file upload flow. Moreover, I'm looking for guidance on what the expression for 'Folder Path' in the 'Create file' action within the flow should be to ensure all files are uploaded to the newly created single folder.
Could anyone offer insight into how I should structure the PowerApps trigger input and the 'Create file' folder path expression in Power Automate to achieve this functionality?
Any examples or pointers would be greatly appreciated!
Below is the OnSelect of the button is PowerApps if that's helpful:
// Step 1: Run 'Create_new_folder' flow and store folder path
Clear(collFolderPath);
Collect(collFolderPath, Create_new_folder.Run());
Set(folderPath, First(collFolderPath).foldername);
// Step 2: Check if folder creation is successful
If(
IsBlank(folderPath),
Notify("Error in creating folder", NotificationType.Error),
// Step 3: If folder created successfully, upload files to folder
Clear(collResult);
ForAll(
'DataCardValue22_1'.Attachments As file,
Collect(
collResult,
'Upload_file_to_sharepoint'.Run({
contentBytes: file.Value,
name: file.Name,
folderPath: folderPath // Passing the folder path to the flow
}).response
)
);
// Step 4: Check for errors in file upload
If(
LookUp(collResult, Value = "Error Occured").Value,
Notify("Error Occurred in file upload", NotificationType.Error),
Notify("Attachments uploaded successfully", NotificationType.Success)
)
);
Thank you in advance for your help!