cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jasirqadri123
Helper I
Helper I

Delete Multiple lines in gallery

Hi Everyone,

 

I have created a delete button where I have inserted a pop up which shows whether to delete item or not

 

On Yes button, I have below formula used to delete only saved items .But I want multiple items to be done at once.

 

Set(linestatus,Gallery.Selected.LineStatus;);If(linestatus = "Saved", Remove(Optics,Gallery1_9.Selected));UpdateContext({showDialog:false})&& If(linestatus="Submitted",Notify("Cannot Delete Submitted Line",NotificationType.Error));

 

check box is also used .

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @jasirqadri123,

Have you solved your problem?

Do you want to bulk delete the records with saved line status once you click the yes button?

 

I have a test on my side, please check for details. Note that coldeleted is my data source populating the Gallery.

Set the OnSelect of the Gallery as below:

 

If(
    Gallery28.Selected.Status.Value = "Completed",
    Collect(
        colSaved,
        Gallery28.Selected
    )
)

 

Set the OnSelect of the yes button as below:

 

ForAll(colSaved,RemoveIf(coldeleted,ID=colSaved[@ID]))

 

At this time, only saved items could be deleted.

Best Regards,
Qi

View solution in original post

3 REPLIES 3
timl
Super User
Super User

@jasirqadri123 

I'd suggest that you explore the use of the RemoveIf function. This will enable you delete multiple records based on a condition.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-remove-removeif

 

Ben_Hoople
Advocate I
Advocate I

What i've done in the past is had another variable that i stored the table data in, 

 

then when you want to delete the items, set the filter for the variable using the Filter() function and set it to the records you want to delete.

 

You can use this code like : 
RemoveDataSourceTable [, All ] )
ie, Remove(DataConnection, Filter(varTableData, x=y), true); or something similar.

 

This is great if you have a one to many relationship, and are trying to cascade delete items.

 

Hope this helps!

v-qiaqi-msft
Community Support
Community Support

Hi @jasirqadri123,

Have you solved your problem?

Do you want to bulk delete the records with saved line status once you click the yes button?

 

I have a test on my side, please check for details. Note that coldeleted is my data source populating the Gallery.

Set the OnSelect of the Gallery as below:

 

If(
    Gallery28.Selected.Status.Value = "Completed",
    Collect(
        colSaved,
        Gallery28.Selected
    )
)

 

Set the OnSelect of the yes button as below:

 

ForAll(colSaved,RemoveIf(coldeleted,ID=colSaved[@ID]))

 

At this time, only saved items could be deleted.

Best Regards,
Qi

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (2,184)