Announcements
I have a SharePoint form which have attachments. now I want to remove all the attachments that are already saved to SharePoint and only add new attachments added to the form when submitting the form. is there a way to achieve this?
thanks
Hi @johnjohnPter ,
// To clear existing attachments ForAll(Gallery1.AllItems, RemoveIf(Attachments, ID = Parent.Default.ID)); // To add new attachments // Assume you have collected new attachments in a collection called 'colNewAttachments' ForAll(colNewAttachments, AddAttachment(SharePointListName, ID, FileName, FileContent));
@Pro_User_365 this will remove them from sharepoint, but when we submit the form again all the attached (old and new ) will get resubmitted? correcT?
Also what is Attachments variable? and how i need to initiate it?
@johnjohnPter ,
Example:
// Save current attachments to a collection ClearCollect(colCurrentAttachments, YourFormName.Attachments); // Remove attachments from SharePoint ForAll(colCurrentAttachments, RemoveIf(Attachments, ID = Parent.Default.ID)); // Clear the attachment control Clear(YourFormName.Attachments); // Add new attachments to SharePoint ForAll(colNewAttachments, AddAttachment(SharePointListName, ID, FileName, FileContent)); // Submit the form SubmitForm(YourFormName);
By doing this, you ensure that only the new attachments are included when you submit your form.
@Pro_User_365 have you tried what you have posted? as they do not make sense to me.. as
ClearCollect(colCurrentAttachments, YourFormName.Attachments);
will contain both the new and the old attachments...
Also what should the colNewAttachments contain??
Hi @johnjohnPter,
Please check this thread:
Solved: Removing files from attachment control - Power Platform Community (microsoft.com)
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.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
11manish 405 Super User 2026 Season 2
Mohsin Ali 368
WarrenBelz 244 Most Valuable Professional