cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerapps890
Post Prodigy
Post Prodigy

Email form based on datacard value

Office365Outlook.SendEmailV2("myemail", Form1.LastSubmit.ReqID &" - "& Form1.LastSubmit.Title&":", "<a href='https://apps.powerapps.com/play/04184d60-38af-480b-91cf-e7369b2b5188?tenantId=5dbf1add-202a-4b8d-815..." & Form1.LastSubmit.ID & "'> Click to view the CR</a> "); This is in the onsuccess of my form.

I want to alter it so that depending on a certain data card value the email is submitted to different people. So for example if one of the datacard values is favorite color blue send it to that user that submitted it and sue. If they choose their favorite color as red send it to that user and dan. So I always want the person submitting to get an email with their form, but then I also want certain people to get it based on the datacard value. Is this possible.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@powerapps890 

Yes, the control type in the datacard is not relevant in this case - you are saying that the underlying datacolumn "FavoriteColor" is a text column. 

Therefore, Form1.LastSubmit.FavoriteColor will be a text value.  AND, I also assume that your Update property on the DataCard for FavoriteColor is set to return a Text value.

 

When you put your cursor right after the FavoriteColor in the formula, what data type does the formula editor tell you it is?  It should be Text.

Office365Outlook.SendEmailV2(
    "myemail" & 
    Switch(Form1.LastSubmit.FavoriteColor,
        "blue", "; sue@mycompany.com",
        "red", "; dan@mycompany.com"
    ), 
    Form1.LastSubmit.ReqID & " - " & Form1.LastSubmit.Title & ":", 
    "<a href='https://apps.powerapps.com/play/04184d60-38af-480b-91cf-e7369b2b5188?tenantId=5dbf1add-202a-4b8d-815..." & Form1.LastSubmit.ID & "'> Click to view the CR</a>"
); 

The syntax of the above formula is accurate.  If you are getting the error that you are, then there is something wrong with one of the parameters of the SendEmailV2 function and is thus complaining that there is an error with one of them.  

 

I am pretty sure that you are not using the above formula verbatim and that we are not really dealing with a "Favorite Color" column but some other one that you are working with.  So, if so, make sure that you are substituting your real column names and choice values (the color names) as well as the email addresses (notice the semicolon and then email) properly.

 

I have vetted the above formula in a sample app and it is fully functional.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

18 REPLIES 18
RandyHayes
Super User III
Super User III

@powerapps890 

In general, your formula would be as follows:

Office365Outlook.SendEmailV2(
    "myemail" & 
    Switch(Form1.LastSubmit.FavoriteColor,
        "blue", "; sue@mycompany.com",
        "red", "; dan@mycompany.com"
    ), 
    Form1.LastSubmit.ReqID & " - " & Form1.LastSubmit.Title & ":", 
    "<a href='https://apps.powerapps.com/play/04184d60-38af-480b-91cf-e7369b2b5188?tenantId=5dbf1add-202a-4b8d-815..." & Form1.LastSubmit.ID & "'> Click to view the CR</a>"
); 

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I tried this and it says an entry is required. I am using a dropdown could that be the reason?? It's not a text field. @RandyHayes 

I tried it with a text field and it still said the entry was invalid. @RandyHayes 

RandyHayes
Super User III
Super User III

@powerapps890 

If it's a dropdown, then you need to base your switch on the selected value of your dropdown control.

Assuming that the control contains a Value column, then this formula would be it:

Office365Outlook.SendEmailV2(
    "myemail" & 
    Switch(Form1.LastSubmit.FavoriteColor.Value,
        "blue", "; sue@mycompany.com",
        "red", "; dan@mycompany.com"
    ), 
    Form1.LastSubmit.ReqID & " - " & Form1.LastSubmit.Title & ":", 
    "<a href='https://apps.powerapps.com/play/04184d60-38af-480b-91cf-e7369b2b5188?tenantId=5dbf1add-202a-4b8d-815..." & Form1.LastSubmit.ID & "'> Click to view the CR</a>"
); 

 

And again, this is assuming that the actual Favorite Color choice column is something that you are storing as part of your form submit...

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

What do you mean a value column? The data card value? I tried using value and it says invalid use of ".". The favorite color column is in the sharepoint list. I just have a form that people input their information then it goes to the sharepoint list. Do I need to add something else? @RandyHayes 

RandyHayes
Super User III
Super User III

@powerapps890 

What kind of column is Favorite Color defined as in your SharePoint list?  You said it's not a Text column.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

It is a text column in the sharepoint this I just meant in the app it is a dropdown

RandyHayes
Super User III
Super User III

@powerapps890 

If it is just a text column, then the first formula should work properly:

Office365Outlook.SendEmailV2(
    "myemail" & 
    Switch(Form1.LastSubmit.FavoriteColor,
        "blue", "; sue@mycompany.com",
        "red", "; dan@mycompany.com"
    ), 
    Form1.LastSubmit.ReqID & " - " & Form1.LastSubmit.Title & ":", 
    "<a href='https://apps.powerapps.com/play/04184d60-38af-480b-91cf-e7369b2b5188?tenantId=5dbf1add-202a-4b8d-815..." & Form1.LastSubmit.ID & "'> Click to view the CR</a>"
); 

What error do you get from it if any?  If so, then a screenshot showing the error would help. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

It is still not working same error message of an invalid entry, it is actually a combobox and then in the datacardvalue default it is ComboBox1.Selected.Value. @RandyHayes 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,994)