cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Required field validation and sending submission confirmation email

Hi,

I need some help on the form validation and sending a notification email.

 

I have created a form using SharePoint list as a data source. There are few mandatory fields which want to validate on the submit button. Using the first part of the code, I am able to validate and submission happens only when all the required fields are filled. However, after adding logic for email notification, I get notification email though fields are blanks. How do I restrict my email notification on the submit button and make sure email is sent only when all the mandatory fields are filled? Quick response is appreciated. 

 

 

If(
!Form1.Valid,
// Then
SubmitForm(Form1),
// Else
If(
IsEmpty(DataCardValue1),
// Then
Notify(
"Failed to submit, fill all required fields and try again.",
NotificationType.Error
),
// Else
ResetForm(Form1);
ResetForm(Form1);
Navigate('Thank you');
Notify(
"Submitted new record.",
NotificationType.Success
);
);

);
Office365.SendEmail(
"abc@xyz.com",
"EPO Intake Form - Submission Confirmation : " & DataCardValue1.Text & " Plot " & DataCardValue1.Text & " : " & User().FullName,
"Hi <b></b>" & Left(
User().FullName,
Find(
" ",
User().FullName
) - 1
) & "," & " <br><br>
Thank you for your submission." & "<br><br><b></b>" & "We will review and respond no later than two (2) business Days. <br><b> <b></b></b>" & " <br> Please feel free to reach out to abc@xyz.com if you have Any questions.<b></b><br>" & "<br>Thanks!",
{
IsHtml: true,
Importance: "Normal",
Cc: User().Email
}
)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: Required field validation and sending submission confirmation email

 

oops...

 

and the check

 

If(FORMVALID, Office365.SendEmail(...))

View solution in original post

2 REPLIES 2
Highlighted
Anonymous
Not applicable

Re: Required field validation and sending submission confirmation email

Hi @satishpandey 

 

Use a context variable and set the value to false by default

 

UpdateContext({ FORMVALID: false })

Update this variable to true only when validation is successful or based on your business criteria.

 

Thanks.

Highlighted
Anonymous
Not applicable

Re: Required field validation and sending submission confirmation email

 

oops...

 

and the check

 

If(FORMVALID, Office365.SendEmail(...))

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,801)