cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jv123
Resolver I
Resolver I

issue with if else then submit on button

I am having issues with this if statement. The submitform executes anyways regardless . Any thoughts?

 

If(CountRows(Gallery1.AllItems) = 0,Notify("Entry Not Saved!"));
If(CountRows(Gallery1.AllItems) > 0, SubmitForm(Form1))

1 ACCEPTED SOLUTION

Accepted Solutions
jv123
Resolver I
Resolver I

Solved it. I forgot about the blank line patch creates. the following below worked:

 

If(CountRows(Gallery1.AllItems) <=1,Notify("Entry Not Saved!"));
If(CountRows(Gallery1.AllItems) > 1, SubmitForm(Form1))

 

View solution in original post

2 REPLIES 2
EddieE
Super User
Super User

@jv123 

Place this into a label to make sure your count is 0 when you think it's 0

CountRows(Gallery1.AllItems)

 

Sounds like something else (like gallery filtering?) is affecting the count.

 

You could also refactor, ie

If(
	CountRows(Gallery1.AllItems) = 0,
	Notify("Entry Not Saved!"),
	SubmitForm(Form1)
)

 

 

jv123
Resolver I
Resolver I

Solved it. I forgot about the blank line patch creates. the following below worked:

 

If(CountRows(Gallery1.AllItems) <=1,Notify("Entry Not Saved!"));
If(CountRows(Gallery1.AllItems) > 1, SubmitForm(Form1))

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,818)