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 / Taking a name from an ...
Power Apps
Answered

Taking a name from an text input and forming an email address to it

(0) ShareShare
ReportReport
Posted on by 156

I created an app where a user can input an employee's name and I'm trying to take that name and make it into our company email.

 

I was able to get this to work however, every time someone runs the app, and the text box is empty, I get this error 

"The second argument to the 'Left' function is invalid.",. Only after someone types something on the text input box will the error go away
 
What do i need to change so that the error wont appear even if it is blank? Please help. Thank you

Formula
 
Text(Lower(Substitute(Proper(Left(ThisItem.'Employee Name',Find(" ",ThisItem.'Employee Name')-1)&"."&Proper(Mid(ThisItem.'Employee Name',Find(" ",ThisItem.'Employee Name')+1,Len(ThisItem.'Employee Name')-Find(" ",ThisItem.'Employee Name')))), " ", "")) & "@companyname.com")
Categories:
I have the same question (0)
  • Verified answer
    v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @JonathanL82 

    You may try to use this code :

     

     

     

    Lower( Proper( First( Split(ThisItem.'Employee Name'," ") ).Value)& If(CountRows(Split(ThisItem.'Employee Name'," "))=1,"", ".")) & Concat( LastN( Split(ThisItem.'Employee Name'," ") , CountRows( Split(ThisItem.'Employee Name'," ") )-1) ,Value ,"") & "@companyname.com"

    Or update your code to this:

    Text(
    Lower(Substitute(Proper( 
     If(Find(" ",Label3.Text) <> Blank() ,
    Left(Label3.Text,
    Find(" ",Label3.Text)-1) , "" )
    &
    If(Find(" ",Label3.Text) <> Blank() ,
    "." , "")
    
    &Proper(Mid(Label3.Text,Find(" ",Label3.Text)+1,Len(Label3.Text)-Find(" ",Label3.Text)))), " ", "")) & "@companyname.com"
    )

     

     

     

    vyueyunmsft_0-1704789662411.png

    Your error code will exist when the Name without sapce like this:
    AniyahahaZhang

     

     

     

    If this reply can help you , you can click mark this reply as solution, thanks in advance!


    Best Regards,

    Yueyun Zhang

  • Verified answer
    WarrenBelz Profile Picture
    156,432 Most Valuable Professional on at

    Hi @JonathanL82 ,

    If you simply want Firstname.Lastname@companyname.com if there is something in the Employee Name

    If(
     Len(ThisItem.'Employee Name') > 0,
     With(
     {
     _Name:
     Split(
     ThisItem.'Employee Name',
     " "
     )
     },
     Proper(First(_Name).Value) & "." & Proper(Last(_Name).Value) & "@companyname.com"
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • JL82 Profile Picture
    156 on at

    @v-yueyun-msft  THank you! this works except for one thing, the first letter in the last name stays upper case if it is typed upper case on the text input box. How can this be changed so it will go lower case too just like the first name. 

  • JL82 Profile Picture
    156 on at

    hi @WarrenBelz thank you for your reply. This one works too but the names if typed in upper case will not be changed into lower case. How can this be arranged?

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    HI , @JonathanL82 

    Yu can try :

    Lower( Proper( First( Split(Label3.Text," ") ).Value)& If(CountRows(Split(Label3.Text," "))=1,"", ".") & Concat( LastN( Split(Label3.Text," ") , CountRows( Split(Label3.Text," ") )-1) ,Value ,"")) & "@companyname.com"
    Text(
    Lower(Substitute(Proper( 
     If(Find(" ",Label3.Text) <> Blank() ,
    Left(Label3.Text,
    Find(" ",Label3.Text)-1) , "" )
    &
    If(Find(" ",Label3.Text) <> Blank() ,
    "." , "")
    
    &Proper(Mid(Label3.Text,Find(" ",Label3.Text)+1,Len(Label3.Text)-Find(" ",Label3.Text)))), " ", "")) & "@companyname.com"
    )

    Both can realize:

    vyueyunmsft_0-1704790155553.png

     

    If this reply can help you , you can click mark this reply as solution, thanks in advance!


    Best Regards,

    Yueyun Zhang

  • JL82 Profile Picture
    156 on at

    @v-yueyun-msft actually your second formula works Thank you sooo much!

  • WarrenBelz Profile Picture
    156,432 Most Valuable Professional on at

    Hi @JonathanL82,

    Simply change Proper to Lower in the code. You will find it significantly less complex and resource demanding than what you have currently.

  • JL82 Profile Picture
    156 on at

    @WarrenBelz this one works too! thank you very much!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard