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.
>