cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
blue_lotus
Level: Powered On

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
Super User
Super User

Re: delete 1 record of a collection

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
Super User
Super User

Re: delete 1 record of a collection

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 Team
Community Support Team

Re: delete 1 record of a collection

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 326 members 1,786 guests
Please welcome our newest community members: