cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lefty
Impactful Individual
Impactful Individual

Notification if fields are empty

Hi,
I need some help please.

I have a save button on a already submitted form, for user2 to enter upto 7 approvers. I wanted the save button to display a notification if User2 attempts to save the form without selecting at least 1 user, I thought this may work, it still present a notification, but still submits the form:

 

If(IsBlank(DataCardValue81.Selected.Email),
If(IsBlank(DataCardValue65.Selected.Email),
If(IsBlank(DataCardValue64.Selected.Email),
If(IsBlank(DataCardValue68.Selected.Email),
If(IsBlank(DataCardValue69.Selected.Email),
If(IsBlank(DataCardValue79.Selected.Email),
If(IsBlank(DataCardValue80.Selected.Email),
Notify("You need to identify at least 1 approver ", NotificationType.Error)
)))))));

SubmitForm(Form1_8);
Office365Outlook.SendEmailV2(Form1_8.LastSubmit........................

 

 

what am i doing wrong please?

1 ACCEPTED SOLUTION

Accepted Solutions

@Lefty 

Ok, I think I misunderstood your original requirements.  Here's my correction.

 

If(
    !IsBlank(DataCardValue81.Selected.Email)
    Or !IsBlank(DataCardValue65.Selected.Email)
    Or !IsBlank(DataCardValue64.Selected.Email)
    Or !IsBlank(DataCardValue68.Selected.Email)
    Or !IsBlank(DataCardValue69.Selected.Email)
    Or !IsBlank(DataCardValue79.Selected.Email)
    Or !IsBlank(DataCardValue80.Selected.Email),
    SubmitForm(Form1_8),
    Notify("You need to identify at least 1 approver ", NotificationType.Error)
)

 

---
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."

View solution in original post

7 REPLIES 7
mdevaney
Super User
Super User

@Lefty 

The problem was your code contained a nested IF statement where all of the datacards had to be blank to show and error message.  You'll want to take advantage of the OR statement instead.

If(
    IsBlank(DataCardValue81.Selected.Email)
    Or IsBlank(DataCardValue65.Selected.Email)
    Or IsBlank(DataCardValue64.Selected.Email)
    Or IsBlank(DataCardValue68.Selected.Email)
    Or IsBlank(DataCardValue69.Selected.Email)
    Or IsBlank(DataCardValue79.Selected.Email)
    Or IsBlank(DataCardValue80.Selected.Email),
    Notify("You need to identify at least 1 approver ", NotificationType.Error),
    SubmitForm(Form1_8)
)
    

 

And you should also move this code to the OnSuccess property of the form so it will only fire when the form is submitted.

 

Office365Outlook.SendEmailV2(Form1_8.LastSubmit........................

 

---
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."

Lefty
Impactful Individual
Impactful Individual

Hi @mdevaney 

Thanks for your response and advice, ive moved the send email to OnSucess of the form, please see error in the syntax i'm getting:

 

 

If Or.PNG

@Lefty 
Your code does not match mine: there are a bunch of open brackets like this  (  in front of your IsBlank functions.

 

---
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."

 

Lefty
Impactful Individual
Impactful Individual

HI @mdevaney 

 

Thanks, that's what i get when I try to modify my existing code

 

I've now published and checked its published, when I have no users in any of the fields and i click submit i get the notification 👍
but after i enter a user in 1 field, and i click submit, i still get the notification appear.

 

If i enter data in all 7 fields i can submit the form.... ideally i need to be able to select just 1 for the notification to not appear and be able to submit the form

@Lefty 

Did you make the changes to your code?  If yes, can you please take a screenshot?

Lefty
Impactful Individual
Impactful Individual

hi @mdevaney 

Yep, Made the changes you pointed out, please see attached:

 

If Or.PNG

@Lefty 

Ok, I think I misunderstood your original requirements.  Here's my correction.

 

If(
    !IsBlank(DataCardValue81.Selected.Email)
    Or !IsBlank(DataCardValue65.Selected.Email)
    Or !IsBlank(DataCardValue64.Selected.Email)
    Or !IsBlank(DataCardValue68.Selected.Email)
    Or !IsBlank(DataCardValue69.Selected.Email)
    Or !IsBlank(DataCardValue79.Selected.Email)
    Or !IsBlank(DataCardValue80.Selected.Email),
    SubmitForm(Form1_8),
    Notify("You need to identify at least 1 approver ", NotificationType.Error)
)

 

---
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."

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.

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 (5,211)