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

Delete Items in Gallery and List

I have a powerapp screen with 2 forms and 2 gallery, that displays an item based on a JSON formula in sharepoint.

Ex. Click on the JSON link (ID#15) in Sharepoint and the links takes you to the PowerApp screen that shows item

ID#15

 

With the item display, I want to click delete, delete items in the Form 1/Form 2 and Gallery,
if the MasterID (Gallery1) = ID_DataCard2/ID_DataCard3 (EditForm1 and EditForm2).
Note EditForm1 and 2 are the same list, it just displays a different views.

 

I originally had a gallery and onselect it show the items assoicated with the ID, but client only wants to see the ID they click in the Sharepoint List. 

 

Formula on Item in Form1 and Form2
Item = If(!IsBlank(Param("ID")),LookUp('Requests',ID = varID),Gallery.Selected)

 

Gallery1
Item = Filter('Test Details', MasterID = Value(DataCardValue1.Text))


Gallery2

Item = 'Test Requests'

 

The problem I am having is, when I try to delete this items it only deletes the items in the form.

 

Its suppose to delete the items in

Request List and Gallery when Form 1/Form 2 ID = MasterID in Gallery

OnSelect on Delete Button:
Remove('Test Requests',Gallery.Selected);
RemoveIf('Test Details', MasterID = Gallery.Selected.ID)

 

6 REPLIES 6
Super User
Super User

Re: Delete Items in Gallery and List

You will have to use Patch to remove the items from the other lists. Remove will work for removing an item in a gallery but if you are removing anything outside the gallery you are clicking in you will need to include a Patch to do that after your remove code. 

crjohnson82
Level: Powered On

Re: Delete Items in Gallery and List

Can automatically selected a item in the gallery using the edit button.. So onselect can set the ID in that gallery to a certain number?

crjohnson82
Level: Powered On

Re: Delete Items in Gallery and List

Or is there a way to filter the gallery by ID?  I cant figure it out..



 

Super User
Super User

Re: Delete Items in Gallery and List

I'm assuming that if you have mulitple galleries and forms that are tied together but different data sources that you have a field that is the same on each of them to connet them. 

 

When you select the first one instead of using the 'Gallery1.Selected.Value' (if you did use that) use 'Set(varItem,Title)' or whatever your field is that is the same in all of them. Then you are setting a variable that you can refer to for your patch. So for the the patch portion you would refer to a LookUp that goes off that variable. Something like:

 

Patch(SPList, LookUp(Title=varItem),{Column1: "New Data",Column2: "New Data"})

Super User
Super User

Re: Delete Items in Gallery and List

Let me see if I can explain this good (I'm better at doing than explaining sometime).

 

Gallery 1

Data Source = SPList1

OnSelect = Set(varItem,ID)

 

Gallery 2

Data Source = SPList2

Items = Filter(SPList2, Title=varItem)

** This is looking if the ID for list one is in the Title column for list 2

 

You could have forms then also that filter for that same variable set (varItem) by using:

Item=LookUp(SPList1, ID=varItem)

or 

Item= LookUp(SPList2,Title=varItem)

 

That one variable is set from the very first gallery selection and then everything else from there can refer to it. It works much better than using Gallery.Selected for LOTS of reasons and using Set is a globar variable meaning it will also work on different screens.

Community Support Team
Community Support Team

Re: Delete Items in Gallery and List

Hi @crjohnson82 ,

Could you please share a bit more about your scenario?

Could you please share a screenshot about your app's configuration?

Does the Gallery1 connect to 'Test Details' data source, and Gallery2 connect to 'Test Requests' data source?

 

Based on the Remove formula you provided, I could not find any syntax error with it. Do you want to automatically selected an item in the Gallery2 when you load your app via clicking the JSON link in your SP List?

 

I have made a test on my side, please take a try with the following workaround:

Set OnStart property of the App control to following:

Set(ItemID, Param("ID"))

Set the Item proeprty of the Edit form1 and Edit form2 to following:

If(!IsBlank(ItemID),LookUp('Requests',ID = ItemID), Gallery.Selected)

 

Set the Items property of the Gallery2 to following:

'Test Requests'

Set the Default property of the Gallery2 to following:

LookUp('Test Requests', ID = ItemID)

When you load your app via clicking the JSON link in your SP List, the corresponding item would be selected automatically within your Gallery2.

 

Modify your Remove formula as below:

Remove('Test Requests', Gallery2.Selected);
RemoveIf('Test Details', MasterID = Gallery2.Selected.ID)

 

Please take a try with above solution, check if the issue is solved.

 

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
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 348 members 4,877 guests
Please welcome our newest community members: