cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
joef
Continued Contributor
Continued Contributor

delete SPO list items

Hi All,

I am trying to create a button on an app that will delete all rows in a SPO list based on criteria in the APP.

 

I am looking for something like 

delete <ListName > where Emailaddress = VarEmail and period = VarPeriod.

 

I am trying to get removeIf and remove to work, but they keep failing 

RemoveIf(
<listName>,
EmployeeEmailAddress = VarUserID , PeriodName1 = TXT_PeriodName.Text

)

 

I am loading one list from another list of defaults, and if the user/period exist, I need to delete All items, and insert the new.

 

TIA,

Joe

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@joef 

What kind of column is EmployeeEmailAddress?  If it is a Person column, you will need to adjust your formula to the following:

RemoveIf(<listName>,
   EmployeeEmailAddress.Email = VarUserID &&
   PeriodName1 = TXT_PeriodName.Text
)

Otherwise,  what error are you seeing?

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

7 REPLIES 7
RandyHayes
Super User III
Super User III

@joef 

What kind of column is EmployeeEmailAddress?  If it is a Person column, you will need to adjust your formula to the following:

RemoveIf(<listName>,
   EmployeeEmailAddress.Email = VarUserID &&
   PeriodName1 = TXT_PeriodName.Text
)

Otherwise,  what error are you seeing?

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

joef
Continued Contributor
Continued Contributor

Email address is a text field in my list, that gets populated from the app.  My app takes all data from a "defaults" list and patches the gallery to a history list.  The user has the ability to update the defaults before submitting this period's time allocation.

 

The error I am getting is, "The item can't be found".  I tried to use Trim figuring there may be some spaces...

 

Maybe I need to load a gallery with the items for the current period, then loop thru the gallery.allitems and delete one by one?

 

Not as easy as expected 🙂

 

Thanks again,

Joe

joef
Continued Contributor
Continued Contributor

Adding the new gallery pointing to the list I want to delete worked...

I still get an error when the form refreshes that it can't find the item( Because it removed them already :)), but the list is cleared for the one user and the one period...

On to making it pretty.... If it doesn't look good it doesn't work!!

 

thanks again!

Joe

RandyHayes
Super User III
Super User III

@joef 

Yes, it is easier than you are making it.  You don't need another Gallery to do this - main reason is that you are using a Gallery as a table in that case, an you can do that all in your formula.

 

So, what is your formula that you were getting errors from?

A screenshot would be helpful as well.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
joef
Continued Contributor
Continued Contributor

I was using your RemoveIf() from the gallery that was pointing to my default list and it threw the error.  No screenshot the error doesn't get captured in a screen shot.

I added a new screen with a gallery that points to my criteria, user = user and period = period.

I added a button and your code, and it works like a charm.  I believe the "Can't find item" error after it deletes the rows was only when I was playing the APP with the designer...  After I published it and ran it all is good 🙂

 

Thanks again for all your help!!

RandyHayes
Super User III
Super User III

@joef 

Was it that you had the button inside the gallery?  

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
joef
Continued Contributor
Continued Contributor

Hi @RandyHayes ,

It was in the gallery screen but not the gallery form. 

But I needed to setup a gallery to display if the user already submitted for the period, so it just kinda worked out 🙂

 

I am sure there are better ways, but as I create more, I learn more... 

 

Thanks Again,

Joe

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,064)