cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AdamD
Helper III
Helper III

Problem sending custom email in SharePoint Integrated App

Hello,

 

I have a custom form built using powerapps which I'm configuring notifications for. When a user submits a new item, I need an email to go out alerting people that a new item is created. I also want to capture data from that form, such as the item's due date, project number, etc. The email code is run on an item's OnSuccess property. I thought I could collect this information by just using the form data card values, but it turns out that the notifications sent out are always one submission behind. That is, after a user clicks Save, the due date, project number, and rest of the data stored, is from submission before them.

I thought maybe I could get around this by invoking ThisItem.[thefield], but that too does not appear to work. I've thought of setting variables to items OnChange properties and then using the variables instead, but that doesn't seem to be working well either. I'm starting to think that the only way around this particular issue is to create a new Save button inside the form, but if that is the workaround I'll have to teach all my users not to click the save button that the SharePoint list puts on it by default... not ideal.

Any advice?

My guess is that this is because of the fact that the SharePoint integrated "Save" button

2 ACCEPTED SOLUTIONS

Accepted Solutions
VijayTailor
Resident Rockstar
Resident Rockstar

Hi @AdamD ,

Please select the Form and Set the OnSuccess Property.

And add the Request Data Like FormName.LastSubmit.ID,FormName.LastSubmit.User.Email. Like That

Office365Outlook.SendEmailV2(Text(Form6.LastSubmit.MyUser.Email),"Subject","BOdy");//Or
Office365Outlook.SendEmailV2(Text(User().Email),"Subject","BOdy"); //This email send to the Current user who created Request

VijayTailor_0-1602189569008.png

Thanks,
Vijay

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay

View solution in original post

@AdamD 

You have a logical AND in your html formula.  That is why you are seeing "false".

 

Please replace your formula with the following:

 

 

Office365Outlook.SendEmailV2(
    "MyEmail@domain.com",
    "New Request Created",
    "<p>
        <span>Hello,</span>
     </p>
     <p><span>You have a new job request from <strong>" & NewForm.LastSubmit.'Requestor Name'.DisplayName & "
         </strong> for <strong>" & NewForm.LastSubmit.'Project Number' & "</strong> 
         <strong>" & NewForm.LastSubmit.'Job Name' & " " & NewForm.LastSubmit.'Type of Document'.Value & ", 
         </strong>submitted by <strong>" & User().FullName & "</strong>, which is due by <strong> " & NewForm.LastSubmit.'Due Date' & " "&"
         </strong>. Please <a href='http://linktosharepointlist.com'>login here</a> to review details and assign a Request Lead within 2 hours.</span>
     </p>
     <p><span><strong>Special instructions:</strong>" & NewForm.LastSubmit.'Special Instruction' & "</span></p>
     <p><span>--</span></p>
     <p><span style='font-size:medium;'>Request Processing System</span></p>",
     {From: "SystemEmail@domain.com"}
);

 

 

 

FYI - LastSubmit is always available on an editform regardless of existing or new record.

 

I hope this is helpful for you.

 

EDIT: also, you can use single quotes in your html rather than putting the Char(34)'s in.

_____________________________________________________________________________________
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

6 REPLIES 6
WarrenBelz
Super User
Super User

Hi @AdamD ,

You need the LastSubmit() property of the form you have just submitted. For instance if you were looking for the field Widget, the reference would be 

Self.LastSubmit.Widget

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

VijayTailor
Resident Rockstar
Resident Rockstar

Hi @AdamD ,

Please select the Form and Set the OnSuccess Property.

And add the Request Data Like FormName.LastSubmit.ID,FormName.LastSubmit.User.Email. Like That

Office365Outlook.SendEmailV2(Text(Form6.LastSubmit.MyUser.Email),"Subject","BOdy");//Or
Office365Outlook.SendEmailV2(Text(User().Email),"Subject","BOdy"); //This email send to the Current user who created Request

VijayTailor_0-1602189569008.png

Thanks,
Vijay

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay

View solution in original post

I was really hoping LastSubmit would be the answer here, but I don't think it works when we're creating a new item. If I'm creating a new item and I use Self.LastSubmit.Anything I get an email whose body simply says "False". It could be that I've done it wrong somehow, but I'm not seeing any red underlines indicating I did anything wrong. Here's an example of the code:

Office365Outlook.SendEmailV2(
"MyEmail@domain.com",
"New Request Created",
"<p><span>Hello,</span></p><p><span>You have a new job request from <strong>"&NewForm.LastSubmit.'Requestor Name'.DisplayName & "</strong> for <strong>"&NewForm.LastSubmit.'Project Number'&"</strong> <strong>"&NewForm.LastSubmit.'Job Name'&" "&NewForm.LastSubmit.'Type of Document'.Value&", </strong>submitted by <strong>"& User().FullName&"</strong>, which is due by <strong> "&NewForm.LastSubmit.'Due Date'&" "&"</strong>. Please <a href="&Char(34)&"http://linktosharepointlist.com"&Char(34)&">login here</a> to review details and assign a Request Lead within 2 hours.</span></p><p><span><strong>Special instructions:</strong>"&&NewForm.LastSubmit.'Special Instruction'&"</span></p><p><span>--</span></p><p><span style="&Char(34)&"font-size:medium"&Char(34)&">Request Processing System</span></p>",{From: "SystemEmail@domain.com"});

I also tried Self.LastSubmit.Value instead of NewForm.LastSubmit.Value. Still no dice there either. Wondering if I might just have to build it in Flow instead of PowerApps. That'd make me sad.

@AdamD 

You have a logical AND in your html formula.  That is why you are seeing "false".

 

Please replace your formula with the following:

 

 

Office365Outlook.SendEmailV2(
    "MyEmail@domain.com",
    "New Request Created",
    "<p>
        <span>Hello,</span>
     </p>
     <p><span>You have a new job request from <strong>" & NewForm.LastSubmit.'Requestor Name'.DisplayName & "
         </strong> for <strong>" & NewForm.LastSubmit.'Project Number' & "</strong> 
         <strong>" & NewForm.LastSubmit.'Job Name' & " " & NewForm.LastSubmit.'Type of Document'.Value & ", 
         </strong>submitted by <strong>" & User().FullName & "</strong>, which is due by <strong> " & NewForm.LastSubmit.'Due Date' & " "&"
         </strong>. Please <a href='http://linktosharepointlist.com'>login here</a> to review details and assign a Request Lead within 2 hours.</span>
     </p>
     <p><span><strong>Special instructions:</strong>" & NewForm.LastSubmit.'Special Instruction' & "</span></p>
     <p><span>--</span></p>
     <p><span style='font-size:medium;'>Request Processing System</span></p>",
     {From: "SystemEmail@domain.com"}
);

 

 

 

FYI - LastSubmit is always available on an editform regardless of existing or new record.

 

I hope this is helpful for you.

 

EDIT: also, you can use single quotes in your html rather than putting the Char(34)'s in.

_____________________________________________________________________________________
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

Bless you, @RandyHayes Randy. I've never been so thrilled to be called out on such a dumb error.

And thank you @VijayTailor and @WarrenBelz who helped me with this. This is one of the best communities I've ever been a part of.

@AdamD 

No worries...it happens to even the most seasoned of us.

And I am glad you are enjoying the community!  Most here are pretty responsive and friendly 🙂

_____________________________________________________________________________________
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!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,545)