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

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
shailendra74
Level 10

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
shailendra74
Level 10

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.

shailendra74
Level 10

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
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

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