Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Query
Suggested answer

How to Upload attachment behind the scenes(without user actually uploading it) from the canvas app

(0) ShareShare
ReportReport
Posted on by 35
So I am working on Canvas app, where my end goal is to upload the generated pdf to SharePoint List Attachment Column (without using Power automate)
 
The PDF is generated by the app itself by :  Set(myPDF, JSON(PDF('Test Screen',{ExpandContainers: true}),JSONFormat.IncludeBinaryData));
 
I don't see patch function supporting directly uploading pdf to SharePoint list, hence using Form Control for the SPO list - removed all the columns except the Attachments
 
made below changes to Attachments data card:
DisplayMode - DisplayMode.View
visible - false, I don't want user see the attachments at all
Items - [{Name:"test.pdf",Value:Substitute(myPDF,"""","")}]
 
And then Used the Patch function, on a button:
 
Patch(
    SurveyForm,
    LookUp(SurveyFormSurveyForm,ID=User.ID),
   Form.Updates
);
 
and this is throwing error "Field Id is Required" (Not sure where)
 
 
Note: I just tested, where user has manually uploaded the attachment, patch function as expected -  the attachment is visible in the Sharepoint List.
 
What changes i have to made, where generated pdf should auto upload to the attachments control. ?
 
Categories:
  • WarrenBelz Profile Picture
    148,294 Most Valuable Professional on at
    How to Upload attachment behind the scenes(without user actually uploading it) from the canvas app
    An attachment control stores its content in BLOB (Binary Large Object) format and you cannot convert the PDF output to this with anything in Power Apps. The attachment control itself does all the conversion when saving to the destination and the attachment needs to be loaded by it initially.  It is unfortunate you cannot use the quite simple Flow solution and I am not aware of a way to covert this to BLOB and return it with a Flow.
    You might think about patching it to an Image type field in SharePoint.
  • Suggested answer
    ramakrishnachim Profile Picture
    35 on at
    How to Upload attachment behind the scenes(without user actually uploading it) from the canvas app
     
    The catch is I cannot use a power automate flow (Due to an internal connection issue), hence looking for alternate answer.
     
    Is there any way I can use automate for only conversion, but not attachment - (i cannot use the sharepoint connection)
  • WarrenBelz Profile Picture
    148,294 Most Valuable Professional on at
    How to Upload attachment behind the scenes(without user actually uploading it) from the canvas app
    The issue is that the output from the PDF function is not compatible with that expected in an attachment control. So unfortunately, you need to use Power Automate for this - the run code would be something like this (with your Flow name)
    With(
       {
          _File: 
          PDF(
             'Test Screen',
             {ExpandContainers: true}
          )
       },
       AddAttachPDF.Run(
          User.ID,
          {
             file: 
             {
                contentBytes: _File,
                name: "test.pdf"
             }
          }
       )
    )
    and the Flow

     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 770 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 494

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 399

Featured topics