cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ChadVKealey
Level 8

Splitting comma-separated string and returning a specific section

User Display Names in our environment are in the form of LastName,FirstName (don't ask). What I want to do is extract the FirstName (to include in an email). There are two ways I can think of to do this, but I'm not having any luck getting the syntax right on either of them:

 

  • Use the "split" expression to put the two names into a list/array, then retrieve item [1] from the array (assuming they actually went with the industry standard and start the array at item [0]). Downside of this is that (I think) it would require two variables (one array and one string)
  • Use some form the the "substring" expression. I used this a bunch back in the day with SPD 2010 for custom XSLT views and formulas, but I'm kind of rusty. Also, in that context, there was a more specific "substring-after" operator, so I could say "substring-after,','" (or something like that) to return the substring after the comma (which is exactly what I need).

There are probably several other ways to do this that I'm overlooking, but I'm running out of patience trying to figure this out on my own. Any guidance or help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Splitting comma-separated string and returning a specific section

Hi @ChadVKealey

 

I you would like to get the FirstName from the User Display Name,

 

As @Anonymous said, you could use expression below to achieve your needs:

last(split(body('Get_user_profile_(V2)')?['displayName'],','))

 

Also you could take a try with expression below:

first(skip(split(body('Get_user_profile_(V2)')?['displayName'],','),1))

 

 

Please take a try on your side and let me know if your problem could be solved.

 

 

Best regards,

Alice

 

3 REPLIES 3
Anonymous
Not applicable

Re: Splitting comma-separated string and returning a specific section

use the below function to split and get the first name. In this example i am using the output of the Get user profile action under Office 365 users.

 

           last(split(body('Get_user_profile_(V2)')?['displayName'],','))
 
Logic is to split the string delimited by ',' into an array and then fetch the last element of the array
Community Support Team
Community Support Team

Re: Splitting comma-separated string and returning a specific section

Hi @ChadVKealey

 

I you would like to get the FirstName from the User Display Name,

 

As @Anonymous said, you could use expression below to achieve your needs:

last(split(body('Get_user_profile_(V2)')?['displayName'],','))

 

Also you could take a try with expression below:

first(skip(split(body('Get_user_profile_(V2)')?['displayName'],','),1))

 

 

Please take a try on your side and let me know if your problem could be solved.

 

 

Best regards,

Alice

 

ChadVKealey
Level 8

Re: Splitting comma-separated string and returning a specific section

Thanks, that did exactly what I was looking for!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

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!

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!

Top Kudoed Authors
Users Online
Currently online: 186 members 4,686 guests
Please welcome our newest community members: