I have a form with 2 buttons, SUBMIT and SAVE. I want it to send email to a user based on the button that is used, so if they click the SUBMIT button an email would go out saying a New form was submitted. If they click the SAVE button, it would send an email saying the form was Updated. It's currently sending out 2 emails, I only want it to send one or the other.
On the SUBMIT button I have this for OnSelect property:
Set(varFormStatus,"Saved"); SubmitForm(EditForm); Notify("The form was saved successfully",NotificationType.Success,0)
On the SAVE button I have this for OnSelect property:
Set(varFormStatus,"Updated"); SubmitForm(EditForm); Notify("The form was saved successfully",NotificationType.Success,0)
On the EditForm I have this on the OnSuccess property:
If(varFormStatus, "Pending";Office365Outlook.SendEmailV2(
"myemail@EMAIL.com",
"New Reallocation Request",
"Hello " & User().FullName &
"<a href='https://apps.powerapps.com/play/e/default-3e1c8459-76b0-41e2-9384-08b8e6adadbc/a/ab1b-0fe6287f23ca?tenantId=3e1c86adadbc&hint=f70326e4-b7&sourcetime=2023-08-18%2014%3A31%3A04Z'> Form Link ,</a>"
));
If(varFormStatus, "Updated";Office365Outlook.SendEmailV2(
"myemail@EMAIL.com",
"Reallocation Request Updated",
"Hello " & User().FullName &
"<a href='https://apps.powerapps.com/play/e/default-3e1c8459-76b0-41e2-9384-08b8e6adadbc/a/ab1b-0fe6287f23ca?tenantId=3e1c86adadbc&hint=f70326e4-b7&sourcetime=2023-08-18%2014%3A31%3A04Z'> Form Link ,</a>"
));
It's sending out both emails 😞
Hi @Jambou,
That is certainly possible, you will have to add a patch function to your Switch value:
Switch(
varFormStatus,
"Pending",
Office365Outlook.SendEmailV2(),
"Updated",
//Add a Semicolon after your SendEmailV2() to add an additional function
Office365Outlook.SendEmailV2();
Patch(
//Change DataSource to the correct name
DataSource,
Self.LastSubmit,
//Change Updated to the correct choice text
{Status: {Value: "Updated"}}
)
)
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!
Hi @LaurensM ,
This works great, using Switch is a much better way to do this. Thank you!
If I have a "Status" choice list field in my SharePoint data source, is there a way to update that column at the same time when the button it clicked? So for example, if the Updated button is clicked, it would send the email and also update the "Status" field in SharePoint?
Is this possible?
Hi @Jambou,
With an If() statement you will have to provide the full condition:
If(
//see = "Updated"
varFormStatus = "Updated",
true,
//false is optional, remove the comma after true to only provide a true parameter
false
)
What I would recommend is using a Switch statement:
Switch(
varFormStatus,
"Pending",
EMAIL_CODE_PENDING_HERE,
"Updated",
EMAIL_CODE_UPDATED_HERE
)
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!