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

OnRemove file collection

Hi Everyone, 

 

I have created an attachment system where each time an attachment is added the display name and file name is changed to include a category from a drop-down. That info is stored in a collection. 
I am then using that collection to control check boxes that will in turn control if the visibility of the submit button is shown or not. 

Where I am having an issue is if a user removes a file from the attachments box currently the check box stays selected as true as it's not automatically removed from the collection.
I have tried to use the OnRemoveFile in the attachments but have been unable to come up with a formula that works to remove it from the collection. 
Any help would be great. 

 

8 REPLIES 8
BlessedCobba
Responsive Resident
Responsive Resident

are you able to run a ClearCollect in the OnRemoveFile property? 

I can but that removes the whole collection where I only want to remove the single record. 

BlessedCobba
Responsive Resident
Responsive Resident

@TimWatts There is a few ways around it. without knowing exactly how your are sending the data to the collection. 

 

If you want to remove a single record from a collection my initial suggestion would be create a hidden gallery that you can filter based on the contents of the attached file, then on the OnRemoveFile can just remove the row that is displayed in the gallery as opposed to using a clearcollect 

This is the code I am using. which is in the "OnAddFile" section of the attachments.

 

ClearCollect(
colAttachments,
Self.Attachments
);
UpdateIf(
colAttachments,
!(First(
Split(
DisplayName,
" - "
)
).Result in colAttachTags),
{
Name: Dropdown1.Selected.Value & " - " & Name & " " & Today(),
DisplayName: Dropdown1.Selected.Value & " - " & Name & " " & Today()
}
);

BlessedCobba
Responsive Resident
Responsive Resident

2 Options i can think of 

1. try the gallery idea i suggested 


2. you could try on the removefile 

RemoveIf(
colAttachments,
!(First(
Split(
DisplayName,
" - "
)
).Result in colAttachTags)
);

Second one didnt work. 
I'll spend some time wrapping my head around option 1 and give it a go. 

To go a different way do you know a formula that would show true if the attachment section contained a file that contained a keyword?
There will be multiple attachments.
Can't be an exact match e.g "may" file name "may audit log"

 

BlessedCobba
Responsive Resident
Responsive Resident

in power apps you use "in" when you are trying to do contains so 

 

If("keyword" in thing, true value, false value) 

Have been trying that one but for some reason, it won't work. 
If the search value matches the file name perfectly it will work but not if I only use a part like I need to. 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,886)