web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Controls Should Only b...
Power Apps
Answered

Controls Should Only be Visible in Specific Item of Gallery

(0) ShareShare
ReportReport
Posted on by 5,325 Super User 2025 Season 2

I have Gallery1, in which there is a 'Trash' icon that allows the user to delete that item in the gallery with  -
     Remove(Subscriber_Address_List,ThisItem)

There is a desire to provide a message that asks the user if they want to delete this item, to minimize unintended deletes. 

To that end, I have added a Label1 (with the message), and a 'Yes' and 'No' button.

The 'Yes' button now has the Remove(Subscriber_Address_List,ThisItem) formula, as well as Set(varDeleteControlsVisible, false).

The 'Trash' icon now has Set(varDeleteControlsVisible, true).

The 'No' button has Set(varDeleteControlsVisible, false).

My issue, when the 'Trash' icon is pressed the other controls appears in each item of Gallery1. Is there a formula I can use that when the 'Trash' icon is pressed the other control appear only in the item in which the 'Trash' icon was pressed and nowhere else?

Phineas_0-1707334948869.png

Phineas_1-1707335055027.png

 

Categories:
I have the same question (0)
  • Verified answer
    Kirkby Profile Picture
    647 Moderator on at

    Hi @Phineas 

     

    The visibility of the DeleteControl(that has message and buttons) for all items is determined all at once by the variable varDeleteControlsVisible.

     

    Would you try this?
     
    1)TrashIcon - OnSelect :  UpdateContext({selectedItem:ThisItem.KeyOfTheItem});
     
    2)DeleteControl that has Yes/No buttons - Visible : selectedItem = ThisItem.KeyOfTheItem

    Only the selected item has buttons, as determined by the above code that checks which item is selected.

     

     

    confidential_btnshow.png

    Kirkby
     
    (If you found my answer helpful, I'd appreciate it if you could mark it as 'Accept as solution' or give it a thumbs up.)
  • Phineas Profile Picture
    5,325 Super User 2025 Season 2 on at

    What am I doing wrong?

    I only get an error.

    All of the controls are in Gallery1.

    'Trash' icon now has in the 'OnSelect' - UpdateContext({selectedItem:ThisItem.KeyOfTheItem})
    Error: "KeyOfTheItem" isn't recognized".
               "Incompatible type. We can't evaluate your formula because the content variable types are incompatible
                 with the types of values in other places in your app."

    Phineas_2-1707357560905.png


    The 'Yes' delete buttons has - selectedItem = ThisItem.KeyOfTheItem
    Error: "Incompatible types for comparison. These types can't be compare. Error, Error."

    Phineas_4-1707358056258.png

     

     

     

     

     

  • Kirkby Profile Picture
    647 Moderator on at

    Hi.

    The term 'KeyofTheItem' refers to key information that distinguishes items in the gallery, such as ID,S/N or ItemId. KeyOfTheItem was just an example.

     

    Please update 'KeyofTheItem' with the appropriate key name. What is the primary key of the items in the gallery? CML_ID is your P.K in the list   SPO?

     

    If so, ThisItem.KeyOfTheItem ==> ThisItem.CML_ID  🙂 

  • Phineas Profile Picture
    5,325 Super User 2025 Season 2 on at

    Got it.

    Made that 'KeyOfTheItem' change to 'ID'.

    That error went away.

    However, my 'Delete' controls (Label1, 'Yes' and 'No' buttons) are still appearing on each line.

    The below represents what the Visible for each has in it.

    Phineas_0-1707359532311.png

    If I change the Visible to ThisItem.KeyOfTheItem I get errors. I'm sure this is not correct. What should the visible of each?

    Phineas_2-1707360432696.png

     

     

  • Verified answer
    Kirkby Profile Picture
    647 Moderator on at

    varDeleteControlIsVisible is reflected uniformly across all items, so all delete controls will be displayed. The Visible property should be changed to True or False for each individual item at every single time by action of an user, so please enter "selectedItem = ThisItem.ID" instead of using the variable. 

     

    The result of logical expression, "selectedItem = ThisItem.ID" (Don't miss "selectedItem=", and Not ThisItem.Key....) decides Visible value to display the control. 

     

    Additionally, since the Delete control includes two buttons, it is cumbersome to manage the Visible property for each. Placing the Delete Control (with two buttons) in a Container "as a parent" and activating the Visible property of the container with selectedItem = ThisItem.ID would be more convenient. 

     

  • Phineas Profile Picture
    5,325 Super User 2025 Season 2 on at

    Yes, sir.

    That's the ticket!

    One last; The 'Trash' icon has the following in the 'OnSelect' to control the visibility of those delete controls.

    I am now only seeing the controls in the specific item in which the 'Trash' icon is pressed.

    What code should be in the 'Yes' and 'No' buttons to hide them once the are clicked, returning the Gallery to its default state where delete buttons/label are hidden?

    Phineas_2-1707364702911.png

  • Verified answer
    Kirkby Profile Picture
    647 Moderator on at

    UpdateContext({selectedItem:"NOTHING_SELECTED"}) //OnSelect of yes and no button

     

    Any value would work unless it is duplicated with keys in the list. An empty string ("") or meaningless "dkiwjidsdskewdwwew" would also work. That is like setting the visible value to false again as if no item has been selected yet.

     

    If ID is not a text but a number, set a random integer that is not expected to come out from your data  instead

     

    Kirkby

     

  • Phineas Profile Picture
    5,325 Super User 2025 Season 2 on at

    When I put UpdateContext({selectedItem:" "}) in the 'OnSelect' of the 'Yes' button I get an error in and the other two controls.

    Phineas_0-1707367038587.png

     

  • Kirkby Profile Picture
    647 Moderator on at

    what is the error message?

     

  • Phineas Profile Picture
    5,325 Super User 2025 Season 2 on at

     "Incompatible types for comparison. These types can't be compared. Error, Error."

    I only had the formula to the 'Yes' button, as a test.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard