cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
suj
Level: Powered On

Return First word in a string

Hi I would like to build an expression in Flow that returns the first word in a string.  Basically I want to get someone's first name from a user's Display name. I know I can use the action Get Profile to get someones first name instead of the Display Name but we use that field as user's Legal name and it doesn't always make sense.

 

Example User's Display Name in AD is Bob Smith but in AD we have his First name as Robert and last name as Smith.

 

When a flow triggers an email to him I would like the email to start with "Hi Bob" instead of "Hi Robert"

 

Thanks in Advance

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Return Fist word in a string

Hi @suj,

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a "Get user profile (V1)" action, User (UPN) field set to email address or UPN of the user.
  • Add a "Compose" action, Inputs set to following formula:
  • indexOf(body('Get_user_profile_(V1)')?['DisplayName'],' ')
    Add a "Compose 2" action, Inputs set to following formula:
substring(body('Get_user_profile_(V1)')?['DisplayName'],0,outputs('Compose'))

 

The Display Name content on my side as below:10.JPG

Image reference:11.JPG

The flow works successfully as below:12.JPG

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 REPLY 1
Community Support Team
Community Support Team

Re: Return Fist word in a string

Hi @suj,

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a "Get user profile (V1)" action, User (UPN) field set to email address or UPN of the user.
  • Add a "Compose" action, Inputs set to following formula:
  • indexOf(body('Get_user_profile_(V1)')?['DisplayName'],' ')
    Add a "Compose 2" action, Inputs set to following formula:
substring(body('Get_user_profile_(V1)')?['DisplayName'],0,outputs('Compose'))

 

The Display Name content on my side as below:10.JPG

Image reference:11.JPG

The flow works successfully as below:12.JPG

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

thirdImage

New Flow Community Board!

Check out the new Microsoft Flow Community Blog Topic Suggestion board!

fourthImage

Australia Summit

Travel to Melbourne and network with thousands of peers!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 63 members 4,391 guests
Please welcome our newest community members: