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

Targeted Notifications on Form Submission

Hi All,

 

I have a powerapp to allow people to add items to a sharepoint list, but I would like to tailor the notifications based on one of the data card values EG if UVR Lite 1 is selected, email ...., etc for all options in the drop down menu (see below)

 image.png

 

Thanks in advance for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Targeted Notifications on Form Submission

I presume you will want to do this when the form is saved so that you don't send out any notifications if they abandon the form or accidentally chose the wrong item from the list. 

So I would simply use the On Select action associated with your save button to execute a switch (or if) to check the value selected and then send the appropriate email.  The format of the email command is:

Office365.SendEmail("email address you are sending to","subject of email","body of email")

For more information on this command see https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-outloo....

 

As far as invoking the send, it could look something like (assuming dropdown name is Vehicle):

Switch(Vehicle.Selected.Value,
"UVR Lite 1", Office365.SendEmail("email1@domain.com","Notification on " & Vehicle.Selected.Value, "This is to notify you that....",
"Diego V12", Office365.SendEmail.... )
etc.

The correct email, subject and body could be stored in a data source with a Lookup performed before the switch/if to get the right set of data based on the selection.

 

7 REPLIES 7
Super User
Super User

Re: Targeted Notifications on Form Submission

I presume you will want to do this when the form is saved so that you don't send out any notifications if they abandon the form or accidentally chose the wrong item from the list. 

So I would simply use the On Select action associated with your save button to execute a switch (or if) to check the value selected and then send the appropriate email.  The format of the email command is:

Office365.SendEmail("email address you are sending to","subject of email","body of email")

For more information on this command see https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-outloo....

 

As far as invoking the send, it could look something like (assuming dropdown name is Vehicle):

Switch(Vehicle.Selected.Value,
"UVR Lite 1", Office365.SendEmail("email1@domain.com","Notification on " & Vehicle.Selected.Value, "This is to notify you that....",
"Diego V12", Office365.SendEmail.... )
etc.

The correct email, subject and body could be stored in a data source with a Lookup performed before the switch/if to get the right set of data based on the selection.

 

Highlighted
Community Support Team
Community Support Team

Re: Targeted Notifications on Form Submission

Hi @Kieranrb ,

Do you want to send an email when the "UVR Lite 1" is selected within the Vehicle ComboBox?

Could you please share a bit more about the Vehicle column in your SP list? Is it a Choice type column? Do you enable "Allow multiple selections" option for it?

 

Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:

Firstly, you need to add a Office 365 Outlook connection within your app firstly.

Set the OnSelect property of the "Submit" button to following:

If(    /* <- Add formula here */
   "UVR Lite 1" in VehicleComboBox.SelectedItems.Value,
Office365.SendEmail("The email address of a specific user", "Email Subject", "Email Body") );
SubmitForm(EditForm1) /* <-- Submit your form data */

In addition, you could also consider add the following formula within the OnSuccess property of the Edit form to send an email notification:

If(    /* <- Add formula here */
   "UVR Lite 1" in EditForm1.LastSubmit.Vehicle.Value,
    Office365.SendEmail("The email address of a specific user", "Email Subject", "Email Body")
);
Back()

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Kieranrb
Level: Powered On

Re: Targeted Notifications on Form Submission

Hi, thanks, yes that's perfect. Could you explain the look up process? I'm pretty new to all this, but I take it I make an excel table with the menu option then add columns for email address, subject and message?

 

Thanks again.

Community Support Team
Community Support Team

Re: Targeted Notifications on Form Submission

Hi @Kieranrb ,

Have you taken a try with the solution I provided above?

Do you mean that you populate the Vehicle ComboBox with values from your Excel table?

Further, do you also add columns for Email Address, subject, message in your Excel table along with the menu option column?

 

I assume that you add columns for Email Address, subject, message in your Excel table along with the menu option column as below:4.JPG

Within your Edit form, set the Items property of the Vehicle ComboBox to following:

Distinct('YourExcelTable', 'Menu Option')

Set the OnSelect property of the "Submit" button to following:

Office365.SendEmail(
LookUp('YourExcelTable', 'Menu Option' = VehicleComboBox.Selected.Result, Email),
LookUp('YourExcelTable', 'Menu Option' = VehicleComboBox.Selected.Result, Subject),
LookUp('YourExcelTable', 'Menu Option' = VehicleComboBox.Selected.Result, Message)
);
SubmitForm(EditForm1) /* <-- Submit your form data *

Or

Office365.SendEmail(
LookUp('YourExcelTable', 'Menu Option' = VehicleComboBox.Selected.Result).Email,
LookUp('YourExcelTable', 'Menu Option' = VehicleComboBox.Selected.Result).Subject,
LookUp('YourExcelTable', 'Menu Option' = VehicleComboBox.Selected.Result).Message
);
SubmitForm(EditForm1) /* <-- Submit your form data *

 

More details about the LookUp function in PowerApps, please check the following article:

LookUp function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Kieranrb
Level: Powered On

Re: Targeted Notifications on Form Submission

Hi, thanks for the quick reply, I have tried what you suggested but I get a runtime error when I try it, but I cant figure out why, here's my table:image.png

and here's the OnSelect Formula:

Office365.SendEmail(
LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Email),
LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Subject),
LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Message)
);
SubmitForm(EditForm1)

 

This is the error I get:

image.png

 

Is there something I've missed?

 

Thanks

 

 

Community Support Team
Community Support Team

Re: Targeted Notifications on Form Submission

Hi @Kieranrb ,

Based on the error message that you mentioned, I think there is something wrong with the value (Email) you provided for the first argument of the Office365.SendEmail() function.

 

Please check if you have retrieved a proper email address from your Excel table. You could add a Label control within your app, then set the Text property to following:

LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Email)

check if the Label control could show proper email address. Also please check if the email address you specified within the Email column of your Excel table is a valid email address.

 

Also please check if the DataCardValue10.Selected.Value formula could return the selected item within your Vehicle ComboBox properly.

 

If the LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Email) formula could return a proper and valid email address, please consider re-create a new connection to your Office 365 Outlook, then modify your formula as below:

Office365.SendEmail(
                    Trim(LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Email)),
                    LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Subject),
                    LookUp(Table1, Vehicle = DataCardValue10.Selected.Value, Message)
);
SubmitForm(EditForm1)

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Kieranrb
Level: Powered On

Re: Targeted Notifications on Form Submission

Hi, thanks for your help. I have figured it out, the label showed it was including the hyperlink in lookup, so the target address became "mailto:...." I removed the hyperlink from the lookup table and it all works great.

 

Many thanks

Kieran

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 176 members 5,076 guests
Please welcome our newest community members: