Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Power Automate trigger in Power Apps has document attachments error in SharePoint Online List - "Sorry, this document can't be opened for editing."

(0) ShareShare
ReportReport
Posted on by 56

Hi all,

 

My first time posting on this great forum having been a lurker for some time.

 

There is an issue with a Power App that I have built that triggers a Power Automate flow. I’ll explain.

 

I have built a very basic form in PowerApps with 4 fields. One of these fields is an ‘Attach file’ control.

 

When a user clicks the Upload button a workflow is triggered that moves the submitted form and attachment to a designated SharePoint list. Depending on which area of the business they selected on the form (‘select area’ dropdown), is where the form entry will sit, fine so far.

 

I will add that there is also a hidden text field within a card in Power Apps that changes the name of the document to be uploaded to SharePoint, so all documents have a similar naming convention no matter what the name of the document is.

 

PowerApps name change code is shown below:

 

 

 

IfError(
 Office365Users.UserProfileV2(DataCardValue2.Selected.Email).surname & ", " & Office365Users.UserProfileV2(DataCardValue2.Selected.Email).givenName & ", Employee Form " & If(
 Month(Now()) > 6,
 Year(Now()),
 Year(Now()) - 1
 ) & Text(
 Now(),
 "-mm-dd - hh:mm:ss"
 ) & "." & Last(
 Split(
 First(FileAttachments.Attachments).Name,
 "."
 )
 ).Value,
 ""
)

 

 

Workflow:

Whole flow.png

This flow works fine except….

 

….when the flow is run, and the Power Apps form is loaded into its designated SharePoint list, on clicking the attached document within the list row, I receive this error.

Can't be opened for editing.png

Just for further information, here is one of the 10 cases from the 'Switch' (ive had to block some naming out due to confidentiality)

 

 

Case.png

 

Help! I've spent hours searching for solutions for this error but have come across nothing so far that matches this exact issue. I can delve in a little more if required. Thanks so much.

  • eel1 Profile Picture
    56 on at
    Re: Power Automate trigger in Power Apps has document attachments error in SharePoint Online List - "Sorry, this document can't be opened for editing."

    Thank you very much Pstork for your time, very helpful. I have now solved this issue thanks to your help.

  • Verified answer
    Pstork1 Profile Picture
    65,999 Most Valuable Professional on at
    Re: Power Automate trigger in Power Apps has document attachments error in SharePoint Online List - "Sorry, this document can't be opened for editing."

    YOu only need the name parameter if you want to change the name of the file during uploading. The filename with extension part is a string that is a simple filename with the file extension. Something like, "document1.docx". You can get it from the name value of the file in the attachment control. The contentBytes property is the Value property of the file from the attachment control. The file name of the file created by the flow is controlled by what you put in the filename property of the Create File action. You can use the name property of the file: record you upload or some other string you submit as a parameter. In the screenshot above that would be the name parameter. Either way it has to be a valid filename with a file extension like .docx or .pdf. Otherwise the file won't open.

  • eel1 Profile Picture
    56 on at
    Re: Power Automate trigger in Power Apps has document attachments error in SharePoint Online List - "Sorry, this document can't be opened for editing."

    Thanks again for your help Pstork. A couple of questions as I am fairly new to power apps and automate, apologies.

     

    What would I expect to use this part of the code for the 'filename with extension' please? I keep getting 'Run has invalid arguments'. I've experimented with the text from the 'fullfilename.Text' which holds the name change text for the attachment, but to no avail!

    fullfilename.Text,
     {file: {name: <<filename with extension>>, contentBytes: First(FileAttachments.Attachments).Value}

    Am I correct in thinking that I have to add the contentBytes and name parameters to the Power Apps V2 as shown below, before I make any changes to the App code? Eg.

     

     

    name and contentbytes.png

    Or am I miles out here!

     

    Thanks so much Pstork, my head is hurting! 😆

  • Pstork1 Profile Picture
    65,999 Most Valuable Professional on at
    Re: Power Automate trigger in Power Apps has document attachments error in SharePoint Online List - "Sorry, this document can't be opened for editing."

    The spot where you reference the attachment control value is where you need to define a file parameter and send that file as a file record.

    uploadflow.Run(
     DataCardValue2.Selected.Email,
     DataCardValue3.Selected.Email,
     DataCardValue4.Selected.Value,
     fullfilename.Text,
     {file: {name: <<filename with extension>>, contentBytes: First(FileAttachments.Attachments).Value}}
    );
  • eel1 Profile Picture
    56 on at
    Re: Power Automate trigger in Power Apps has document attachments error in SharePoint Online List - "Sorry, this document can't be opened for editing."

    Thank you very much for your response Pstork. Interesting, specifically adding Power Apps V2 as the trigger in the flow and the parameter. 

     

    This is the code for the 'Upload' trigger button btw if that helps for more info, ref: the run in Power Apps.

     

     

    uploadflow.Run(
     DataCardValue2.Selected.Email,
     DataCardValue3.Selected.Email,
     DataCardValue4.Selected.Value,
     fullfilename.Text,
     First(FileAttachments.Attachments).Value
    );
    ResetForm(frmUpload);
    UpdateContext({VarConfirm: true})

     

     So I include the parameter within the app Power Fx code I presume instead of Uploadflow.run?

     

    Thanks a lot!

  • Pstork1 Profile Picture
    65,999 Most Valuable Professional on at
    Re: Power Automate trigger in Power Apps has document attachments error in SharePoint Online List - "Sorry, this document can't be opened for editing."

    1) Remove the Power Apps trigger and use the Power Apps V2 trigger instead. Then instead of createing the parameters using Ask_in_PowerApps you can create them directly in the trigger.  

    2) For the file create a File type parameter as the last parameter in the list.  

    3) include the file parameter as a {file: } record with two keywords Name: and ContentBytes:

    Call your flow using something like this as the run line.

     

     

    UploadFile.Run(NewFileName,
     {file: {name: First(AttachmentControl.Attachments).Name,
     contentBytes: First(AttachmentControl.Attachments).Value}})

    When you create the document in the flow use the NewFileName parameter and the contentBytes parameter.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow