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 / Send an email dependin...
Power Apps
Answered

Send an email depending on the value in a text box

(0) ShareShare
ReportReport
Posted on by 15

I have built an app for controlling maintenance parts in a storage location, I want to send an email when an item drops below a certain minimum value (level) - so the user enters there are 2 left, I want to send an email to say "Please order item x as the minimum stock level has been reached" etc.

 

I have the value entered in lets say DataCard8 but whatever I try to check that value I get syntax errors, how is this done? (checking the value entered by a user in a box) and then send an email copying the other fields on the screen. It's a three screen app from an excel sheet, just cannot find the right syntax. DataCard8.Text is not accepted (gets red lined)

 

Where is all this mystical info kept too? (PowerApp syntax, commands, variables etc) - is it using Java?

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Subsea7,

     

    After submitting the form you can retrieve the values by using FormName.LastSubmit.FieldName

    Change FormName and FieldName to the correct values, in your case this will look similar to:

     

    //I chose Form1 as form name for the example with fictive fields, change if necessary
    //First submit the changes
    SubmitForm(Form1);
    With(
     //Temp save the latest submit to a var named formRecord
     {formRecord: Form1.LastSubmit},
     If(
     //If stock smaller or equals 2
     //If you get an error 'cannot compare text to number' try Value(formRecord.stockField) instead
     formRecord.stockField <= 2,
     Office365Outlook.SendEmailV2(
     "", //Change to the email
     "", //Add a subject
     "" //Add a body
     )
     )
    )

     

    You might need to add the office365Outlook connector to your app for the mail formula to work. (data connector tab in the left-side nav bar)

     

    You can access all fields of the last form submit by using formRecord.FieldName in my code. An example mail subject could be: "Restock needed for " & formRecord.Name

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @Subsea7,

    Could you please tell me if you want to send an email before you submission or after your submission?

    How you defines if an item is below a certain minumum value?

     

    To refer to the input within the data card8, I think you could refer to as below:

    DataCardValue8.Text

    If you want to send the email after your submission, I would suggest you set the OnSuccess property of the form as below:

    If(Form.LastSubmit.Field<="2",//Here depends on your field type,if it is Text, then "2"
     Office365Outlook.SendEmailV2(xxx@xxx.com,Form.LastSubmit.Field1,Form.LastSubmit.Field2,Form.LastSubmit.Field3)
  • Subsea7 Profile Picture
    15 on at

    Thank you to both for replying, I had sort of gotten close myself but I note you are using SendEmailV2 and not just SendEmail, is there a reason to use the V2? (Just trying to understand the difference) - @LaurensM your answer was exactly as I had ended up doing to so have marked it as the correct answer for others who may want to know the same thing. 

     

    @v-qiaqi-msft thank you for replying, I have created a variable and pointed that to the value in the field the user enters for "current stock" which is fine, it sends a mail when the value remaining is less than the min stock.

     

    And how do people learn this syntax for PowerApps? I am a VB.NET developer, normally there is a syntax guide or language reference to work from when learning a new language, this looks like Java or Python type script, so is there a reference for the PowerApps code syntax and functions that I can access? 

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Subsea7,

     

    As a general best practise, it is preferred to use the latest version of a formula / API - hence V2. According to the documentation the V1 is currently deprecated (could be removed in the future).

     

    To add on my previous answer, it is actually best to put the code (the complete with() function) in the OnSuccess of the form instead of right after the SubmitForm in the OnSelect of a button - as was well stated by @v-qiaqi-msft . With the OnSuccess property, you are sure that the code will only trigger if the record / update was successfully sent to the database.

     

    The low-code syntax of Power Apps is called Power Fx - has a lot in common with Excel Formulas. You can find a a lot of info in the Microsoft Power Fx documentation, should you be interested. 

     

    I hope this helps!

  • Subsea7 Profile Picture
    15 on at

    Thank you, you are the first and only person to answer the question of the language used, and syntax. Perfect, very much appreciated.

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard