Delete multiple CDS records from Grid using PowerApps.


In this blog, we will learn how to Delete multiple records of CDS from the Grid.


Use Case:

We have a requirement where there is a Grid of CDS Data Source, on clicking the Delete Icon on top of the Grid, it should delete every record which is selected through the checkbox which is there on every record of the Grid.



Steps to be followed:

1. There is a Screen on which there a Editable grid of Quote Product Entity.

  1. To Create an Editable Grid refer to the following link.

  1. To add Lookup Fields in the Grid refer to the following link.

2. This is the grid with a checkbox.

3. To delete selected records, first create a Collection:
         OnSelect property of the Delete icon:

         Set DeleteIcon.OnSelect = ClearCollect(<VariableName>,Filter(<GalleryName>.AllItems,<CheckBoxName>.Value = true ))

         For eg: DeleteSelectedRecord.OnSelect= ClearCollect(SelectedQuoteProductDelete,Filter(GalleryQuoteProduct.AllItems,CheckboxQuoteProductGallery.Value = true))

4. When we select the Delete Icon, it will collect all the records where the Checkbox is selected.

5. To delete the records from the CDS, set the OnSelect property of the Delete Icon to the following formula:
         OnSelect property of the Delete icon:

         Set  DeleteIcon.OnSelect =  ForAll(<CollectionVariable>,RemoveIf('Gallery Data Source',<GUID you want to delete>))

         For eg: DeleteSelectedRecord.OnSelect =  ForAll(SelectedQuoteProductDelete,RemoveIf( [@'Quote Products'], 'Quote Product' in SelectedQuoteProductDelete[@'Quote Product'] ))

6. Combine the Whole formula in the Set OnSelect property of Set DeleteIcon :

          For eg:  DeleteSelectedRecord.OnSelect =  ClearCollect(SelectedQuoteProductDelete,Filter(GalleryQuoteProduct.AllItems,CheckboxQuoteProductGallery.Value = true));
ForAll(SelectedQuoteProductDelete,RemoveIf([@'Quote Products'],'Quote Product' in SelectedQuoteProductDelete[@'Quote Product'])


Hope above Blog helps you delete multiple records of CDS from the Grid.

Share Story :