cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nico888
Frequent Visitor

Is that possible to patch attachments to sharepoint documents without with flow?

I have a business requirement to upload files to sharepoint documents directly using the native attachment control, I would like to ask if there is such a method that can be used directly.

10 REPLIES 10
RusselThomas
Community Champion
Community Champion

Hi @nico888 ,

I think even with the advice provided here, I believe you still use the attachment 'control' inside a form to select the attachments, even if you don't use the SubmitForm() function to save them.
Are you still wanting to use the control, or somehow patch content directly?

There might be a better way with Flow - can you explain your scenario a little more?

Kind regards,

RT

WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi @nico888 ,

The only way to Patch Attachments in Power Apps is with FormName.Updates. You can of course use SubmitForm(). If by Upload, you are referring to storing in a SharePoint Library, then you cannot do this without Power Automate.

 

Please click Accept as solution 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 Thumbs Up.

Visit my blog Practical Power Apps

I need to upload the attachment to sharepoint documents library but not sharepoint list ,and without use flow

RusselThomas
Community Champion
Community Champion

Hi @nico888 ,

The Power Apps SharePoint connector does not cater for creating document content in a library - you can browse document libraries in Power Apps by connecting to a library as a SharePoint list data source, but this is simply because the frontend to every document library is actually a special kind of list - so all you're actually seeing in Power Apps are document properties.

The actual document content is stored in the backend and is not directly accessible through the connector, so you can neither download nor upload document content using this connector.

 

As @WarrenBelz noted, the easiest way you can achieve this is to use the SharePoint connector available in Power Automate.  You can use the "Add picture" or Attachment control to get document contents from a device into Power Apps - however you need to pass that content data to Power Automate in order save it to a document library using the Create File method.

 

At the far end of the solution spectrum, I guess you could possibly create your own custom connector for SharePoint Online and include a method that allows you to post document content into the SPO REST API - you could connect this connector to your Power App directly and use it - but then you're basically doing a tonne of work just to avoid something that would take less than two minutes in Power Automate, which is kind of like saying "I don't want to walk to the bus stop to catch the bus, so I think I'll build a car instead..."

 

Kind regards,

RT

ok,thanks for your answer !

Thanks for your answer!

HEATFreight
Kudo Kingpin
Kudo Kingpin

How can I do this directly in a canvas app without using Power Automate? Is that possible?

I want to copy the attachments from an item in list A to an existing item in a totally different list, call it list B. It does not seem like PowerApps allows for programmatically copying attachments between items in different SharePoint lists. Can someone confirm if this is true?

See my response in this other thread.

EDIT: 

Aha! I figured it out. If you need to patch attachments from an item in one SharePoint list to an item in a totally different SharePoint list, you must first remove the Attachments.Id parameter from the collection!

I used the following code:

 

ClearCollect(colAttachments,AddColumns(DropColumns(colAttachments,"Id"),"Id",""));
ResetForm(AttachmentsForm);
Patch(SharePointList,LookUp(SharePointList,ID=ThisItem.ID),AttachmentsForm.Updates);

 

Shazam007
Frequent Visitor

Hi I came across your post, I raised a similar problem, then managed to find a workaround 

 

see my post link Solved: Re: Flow versus Office365GroupsHttpRequest Connect... - Power Platform Community (microsoft....

 

I managed to find a solution for the problem (Is it possible to use office365groups.httprequest connector with a Patch or Collection, or maybe a combination , within a Power Apps environment to simultaneously add metadata from sharepoint list to sharepoint document library ? ), see code highlighted in red.

ForAll(DataCardValue52.Attachments,Office365Groups.HttpRequest(" https://graph.microsoft.com/v1.0/sites/..../root:/"&ThisRecord.Name&":/content","PUT",ThisRecord.Value));
Refresh(DocLibAB);
ClearCollect(collastdoclib,Last(DocLibAB));
ForAll(collastdoclib,Patch(DocLibAB,LookUp(DocLibAB,ID=collastdoclib[@ID]),{ProdId2Num:varproditem2.ID}))
*Note*
ProdId2Num is column name within SP Doc lib AB where the value from the SP list A will land
varproditem2.ID is the prod SP LIST ID value from SP list A. This variable was initiated and set when clicked a button within a gallery list item of SP list A. The Button had following on the onselect; Set(varproditem2,thisitem);Navigate(newuploaddoclib)

**More on the Office365Groups.HttpRequest(" https://graph.microsoft.com/v1.0/sites/..../root:/" - check out first Reza Dorani video  : https://youtu.be/n3mhe88BI34 to help to get a better understanding of the first FORALL part

 

Step by Steps:
1.After the first FOR ALL I added a new line; REFERESH of the doc library
2.COLLECTION of that last or latest doclib record just added
3.then a new FORALL to MATCH ID's of Collection with Last Doc Lib AB record ID
4.PATCH the variable containing the Sharepoint list ID value to the Doc Lib AB Column (this is the relational table part wanted to achieve)

After a few test runs Worked... No more flow errors with my flow....Happy Days

Thanks 

Shahzaad

 

 

That looks complicated, but your use case also seems different than mine.

My solution for the use case of wanting to attach files from SharePoint ListA to SharePoint ListB is simple:

If you need to patch attachments from an item in one SharePoint list to an item in a totally different SharePoint list, you must first remove the Attachments.Id parameter from the collection!

I used the following code:

 

ClearCollect(colAttachments,AddColumns(DropColumns(colAttachments,"Id"),"Id",""));
ResetForm(AttachmentsForm);
Patch(SharePointList,LookUp(SharePointList,ID=ThisItem.ID),AttachmentsForm.Updates);

 

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!      

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Top Solution Authors
Top Kudoed Authors
Users online (3,534)