cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
blue_lotus
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
yashag2255
Dual Super User II
Dual Super User II

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
yashag2255
Dual Super User II
Dual Super User II

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

v-xida-msft
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (38,057)