web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problem sending custom...
Power Apps
Answered

Problem sending custom email in SharePoint Integrated App

(0) ShareShare
ReportReport
Posted on by 156

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

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,787 Most Valuable Professional on at

    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.

     

  • Verified answer
    Vijay Tailor Profile Picture
    2,961 on at

    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

  • AdamD Profile Picture
    156 on at

    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.

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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.

  • AdamD Profile Picture
    156 on at

    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.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 519 Most Valuable Professional

#2
11manish Profile Picture

11manish 489

#3
Haque Profile Picture

Haque 327

Last 30 days Overall leaderboard