cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Splitting Name Field(First Name ,Last Name) from an email body

Hi all,

I am working on a email body form scenario where I have to extract Name, Email and Company etc from an email body form to input my UI Flow. Problem is, when I am trying to extract and split Name field (First Name, Last Name), it shows the following result :

 

Here is my flow :

 

emailbody1.PNG

 

Extracting Name:

last(split(body('Convert_email_HTML_to_Text'),'Name:'))
 

emailbody2.PNG

 

First name:

split(outputs('Extracting_Name'),' ')[0]
 
emailbody3.PNG
 

Last Name:

split(outputs('Extracting_Name'),' ')[1]
 
emailbody4.PNG
 
Here in the last output when I am extracting the last name it also coming with the next line Which is Email.
Can anyone please help me on this?
 
Regards,
- Ahmad Khan
3 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

OMG! I forgot about the 'Name:' !!!

So in order to get Fist Name this expression hould do the magic:

split(first(body('Filter_array')),' ')[1]

 

Expression suggested for 'Last Name' is right?

 

last(split(first(body('Filter_array')),' '))

Hope this helps

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body


@Ahmad-KAISPE wrote:

Can you please give me an example for this problem. I would appreciate

 

Regards,

Ahmad


Sure ... let's assume you add a second filter array (let's call it 'Filter array 2'), add a condition to grab the Telephone nr. related line, then I would suggest the following expression:

 

 

join(skip(split(first(body('Filter_array_2')),' '),1),' ')

 

Hope this helps

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

Congrats!

Thanx for your kindness!

 

Thanx for helping to make this community great!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

15 REPLIES 15
Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

Hi!

THe problem is, there is not a space between 'Ahmad' and 'Email:' but a NewLine instead

Did you consider this alternate approach?

first(split(split(outputs('Extracting_Name'),' ')[1],'
'))

Just remember to hit enter

 

IF problem is not solved this way, please let us know

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Helper II
Helper II

Re: Splitting Name Field(First Name ,Last Name) from an email body

Thank you for your response.

 

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

Hi!

JUst edited my first response with one suggestion

THanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Helper II
Helper II

Re: Splitting Name Field(First Name ,Last Name) from an email body

 

I

 
Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

Hi again!

Add a Compose action block and assign as its input this expression instead

split(trim(uriComponentToString(replace(uriComponent(body('Html_to_text')),'%0A','~~'))),'~~')

If this second approach works, its output will be an array, each element a line from your email.

 

NExt you will need to add a 'Filter array' to extract the line with 'Name:' inside, assign as its input this expression from above, now configure its condition rule to verify if current item() contains 'Name: '

Finally, you will need to get first result from 'Filter array' output and split it by using space delimiter

HOpe this makes sense



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Helper II
Helper II

Re: Splitting Name Field(First Name ,Last Name) from an email body

Hi 
Thank you for you patience

I am facing this error when I am trying to split my name into first and last name:

 

emailbody7.PNG

 

Regards,

Ahmad

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

Hi!

No problema, we are very close to a Happy Ending!

Please note that Filter array output is also an Array, even though this one has a single element. So the error is reporting this problem

I believe you need to change your current expression in 'First Name' compose action block, please try with this other instead:

first(split(first(body('Filter_array')),' '))

 

Now, 'Last Name' should be something similar

last(split(first(body('Filter_array')),' '))

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Helper II
Helper II

Re: Splitting Name Field(First Name ,Last Name) from an email body

I am still not getting the desire result:

 

emailbody6.PNG 

 

Regards,

Ahmad

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

OMG! I forgot about the 'Name:' !!!

So in order to get Fist Name this expression hould do the magic:

split(first(body('Filter_array')),' ')[1]

 

Expression suggested for 'Last Name' is right?

 

last(split(first(body('Filter_array')),' '))

Hope this helps

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted
Helper II
Helper II

Re: Splitting Name Field(First Name ,Last Name) from an email body

Thank you   for your help. it works successfully.

 

now when I am following further steps and input the same spilt function on Phone field from an email body it gives me this following result:

 

Phone: 

split(first(body('Filter_array')),' ')[1]

 

emailbody8.PNG

 

Regards,

Ahmad

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

Hi!

Did it finally work? Congrats!

 

Now, your new challenge... I believe the problem is you are using space as separator, and your phone number has also spaces inside. So, you need a different approach for your expression. Did you considered combining split(), skip() and join()?

Hope this helps

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Helper II
Helper II

Re: Splitting Name Field(First Name ,Last Name) from an email body

Can you please give me an example for this problem. I would appreciate

 

Regards,

Ahmad

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body


@Ahmad-KAISPE wrote:

Can you please give me an example for this problem. I would appreciate

 

Regards,

Ahmad


Sure ... let's assume you add a second filter array (let's call it 'Filter array 2'), add a condition to grab the Telephone nr. related line, then I would suggest the following expression:

 

 

join(skip(split(first(body('Filter_array_2')),' '),1),' ')

 

Hope this helps

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted
Helper II
Helper II

Re: Splitting Name Field(First Name ,Last Name) from an email body

Thank you so much  it worked.

 

Regards,

Ahmad

Highlighted
Dual Super User
Dual Super User

Re: Splitting Name Field(First Name ,Last Name) from an email body

Congrats!

Thanx for your kindness!

 

Thanx for helping to make this community great!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (8,607)