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

Repeating sections, prevent deleting last line?

I've followed Shane Young's YT series on making a repeating section. I have a question regarding the details gallery. Is there any way to prevent a user from accidentally removing the last line in a gallery?

1 ACCEPTED SOLUTION

Accepted Solutions
notj
Level: Powered On

Re: Repeating sections, prevent deleting last line?

@mdevaney  thanks for getting me there. I wound up using this for the Visible property on the Delete Row button:

 

If(CountA(Collection.Column)=1, false, true)

 

View solution in original post

6 REPLIES 6
Super User
Super User

Re: Repeating sections, prevent deleting last line?

@notj 

My assumption is your Gallery will be ordered from lowest to highest ID. You can use the MAX function to determine the greatest value within the field ID .  Put this code in the DisplayMode property of your delete record button.

 

If(ThisItem.ID = Max(your_datasource_name,ID), Disabled,Edit)

 

Note: I've not watched Shane's video on this topic so I am making some assumptions here.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

notj
Level: Powered On

Re: Repeating sections, prevent deleting last line?

I feel like you're definitely on to something here. I'm not currently keeping track of ID though. My datasource is just a collection with a single text column in it. Would I need to build an incrementing ID column in it, or do you think I could use something like Count? Maybe if I count the rows in the collection and it's equal to 1?

notj
Level: Powered On

Re: Repeating sections, prevent deleting last line?

@mdevaney  thanks for getting me there. I wound up using this for the Visible property on the Delete Row button:

 

If(CountA(Collection.Column)=1, false, true)

 

View solution in original post

Super User
Super User

Re: Repeating sections, prevent deleting last line?

There was a misunderstanding here about what you wanted to do. If there was a gallery with 5 lines I thought you wanted the LAST row 5 to not be deleted. Instead, you wanted delete to be disabled if a gallery had only a single row. That’s why my response probably did not make sense to you
notj
Level: Powered On

Re: Repeating sections, prevent deleting last line?

Ah, yea! I see what you mean. In my mind, you had multiple lines and you were deleting them 1 by 1. At some point, your last line(meaning the last one remaining) I wanted to prevent being deleted. Not actually THE last line in the collection. I see how my explanation was confusing haha.

Super User
Super User

Re: Repeating sections, prevent deleting last line?

@notj 

Clear communication = Hard. 

Clear communication + Internet = Impossible. LOL.

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 (Last 30 Days)
Users online (5,733)