Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

How do I remove the item in a gallery AND all related items in a secondary list (using a delete icon in a gallery)

(0) ShareShare
ReportReport
Posted on by 280

I have a gallery that I added a 'delete' icon to.

In the OnSelect property, I added code that I expected to delete "ThisItem" from a PARENT list, and also attempts to remove the related items in a CHILD list.

 

The Child list has a column called 'Ref ID' that identifies and links its items to their respective Parent item in the main list.

 

** The code below deletes the Parent item from its list as expected, but it isn't removing the items from the Child list.

RemoveIf(ChildList, 'Ref ID' = ThisItem.ID);
Remove(ParentList, ThisItem)

 

Any assistance is greatly appreciated.

  • Verified answer
    rkirk2k Profile Picture
    rkirk2k 280 on at
    Re: How do I remove the item in a gallery AND all related items in a secondary list (using a delete icon in a gallery)

    Thanks for the reply. I figured this out yesterday - I needed to convert ThisItem.ID to text and it worked perfectly.

     

    Also - I wasn't using a lookup column. Not sure where that came from. Again - I appreciate you engaging.

  • WarrenBelz Profile Picture
    WarrenBelz 145,666 on at
    Re: How do I remove the item in a gallery AND all related items in a secondary list (using a delete icon in a gallery)

    Hi @rkirk2k ,

    You just have them the wrong way around

    RemoveIf(
     ChildList, 
     'Ref ID' = ThisItem.ID
    );
    RemoveIf(
     ParentList, 
     ID = ThisItem.ID
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • LaurensM Profile Picture
    LaurensM 12,510 on at
    Re: How do I remove the item in a gallery AND all related items in a secondary list (using a delete icon in a gallery)

    Hi @rkirk2k are the lists your are refering to SharePoint lists?
    If so, this can be done on List / data source level: (1) go to the LookUp column's settings, (2) more options and use the settings below:

    LaurensM_0-1671226124953.png


    If you want to only use the button, try this adjustment:

    RemoveIf(ChildList, 'Ref ID'.ID = ThisItem.ID);

     

    If this solves your question, would you be so kind as to accept it as a solution.
    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard