cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver I
Resolver I

Extract first name from string

Hi,

 

I have an issue around the identifying the app user. Chiefly as all users will be using the one device to access the apps so it will be a generic user name.

To get around this I am using an intro screen asking people to 'log-in' by entering their name - which is checked against Office 365 user list - and then navigates to a menu screen.

However, there are places within the app where I would like to use their first name rather than Selected.DisplayName

I have tried First(Split(Label1.Text," ").Result but this isn't working as it appears to want a "Sting" rather than Label1.Text.

Any ideas how I can extract the first name please.

1 ACCEPTED SOLUTION

Accepted Solutions

@KevinHardy 

Can you please send a screenshot of your workspace?  I'd like to see what your app looks like and the error highlighted in the formula bar.

 

Note: this formula was missing a close bracket

First(Split(DataCard_UserName.Selected.DisplayName," ")).Result

View solution in original post

5 REPLIES 5
Super User III
Super User III

@KevinHardy
Your formula strikes me as being correct but would it be possible to replace Label1.Text with a reference to the ComboBox holding the UserName instead? It should extract the FirstName

First(Split(ComboBox_UserName.Selected.DisplayName," ")).Result

By the way what type of control are you putting this formula into? This could also be the reason for the error

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

Hi @mdevaney ,

 

I'm putting the formula into the text property of a label: "Hello " & First(Split(DataCard_UserName.Selected.DisplayName," ").Result

It's still says it's expecting text instead of DataCard_UserName? I know you can create a string using Text( but wouldn't know how or where to put it within this formula.

DataCard_USerName is a Combo Box that checks the name against Office365 users

Kev

As an alternative solution, you could ask the user to enter a preferred name then store that in a data source (SharePoint) with their Office365 info. Then use that throughout the app? You'd only need to do this once. Just a thought

@KevinHardy 

Can you please send a screenshot of your workspace?  I'd like to see what your app looks like and the error highlighted in the formula bar.

 

Note: this formula was missing a close bracket

First(Split(DataCard_UserName.Selected.DisplayName," ")).Result

View solution in original post

Hi @mdevaney , thanks for this. It was the missing bracket 🙂

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (22,546)