cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ahmad-KAISPE
Helper V
Helper V

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

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


@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

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
efialttes
Super User III
Super User III

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!



Thank you for your response.

 

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!



 

I

 

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!



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

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!



I am still not getting the desire result:

 

emailbody6.PNG 

 

Regards,

Ahmad

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

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

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!



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

 

Regards,

Ahmad


@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

Thank you so much  it worked.

 

Regards,

Ahmad

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,409)