cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

delete 1 record of a collection

hi 

I have a collection that contains many records.

Can I delete only 1 record from the collection, instead of dlearing the whole collection.

Until now, I use clear (collection_name)

But ideally, i would like to check that
for each record of the collection, 
-if the record exist in the data source, then I delete it form the collection
-if it doesn't exist in the data source, then nothing

is it possible to do something like that?
can someone help me write it?

 

thank you v much

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Hi @blue_lotus 

 

You can use the Remove/ RemoveIf function to remove a certain number of rows from your collection.
 
Expression: RemoveIf(MyLocalCollection, Title in DataSource.TitleCol)
 
Here MyLocalCollection refers to the Name of my collection with a column Title(for which we want to match the condition), and DataSource refer to SQL Table with a column "TitleCol". Please replace the used names with your specific attributes.
 
For more info, you can check out the documentation on: 
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

2 REPLIES 2
Highlighted
Dual Super User III
Dual Super User III

Hi @blue_lotus 

 

You can use the Remove/ RemoveIf function to remove a certain number of rows from your collection.
 
Expression: RemoveIf(MyLocalCollection, Title in DataSource.TitleCol)
 
Here MyLocalCollection refers to the Name of my collection with a column Title(for which we want to match the condition), and DataSource refer to SQL Table with a column "TitleCol". Please replace the used names with your specific attributes.
 
For more info, you can check out the documentation on: 
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Community Support
Community Support

Hi @blue_lotus ,

Could you please share a bit more about your Collection and data source that you mentioned?

Do you want to delete the specific record from your Collection if the record has been existed in your data source?

 

I assume that your Collection has a primary column called "CollPrimaryColumn", which could identify one record in your collection uniquely. The "CollPrimaryColumn" column match the corresponding column called "PrimaryColumn" in your data source.

 

I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Remove Records" button to following:

ForAll(
         RenameColumns(YourCollection, "CollPrimaryColumn", "CollPrimaryColumn1"),
          If(
             !IsBlank(LookUp('YourDataSource', PrimaryColumn = CollPrimaryColumn1)),
             RemoveIf(YourCollection, CollPrimaryColumn = CollPrimaryColumn1)
          )
)

Please take a try with above solution, then check if the issue is solved.

 

More details about the ForAll function and RenameColumns function, please check the following article:

ForAll function

RenameColumns function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,466)