0

I have what should be a simple task, but I'm struggling with it. It's a large form, so I'll just stick to what's relevant for my question. So I have a people picker field in my form (customized SharePoint form), and a Text field. When the user populates that People field with whomever they're choosing, I want the Text field to display that user's First and Last Name only. Currently my company's people fields present like this when populated - Shoemaker, Chris (Companyname). I want my Text field to just display, Chris Shoemaker. In that order without the "(companyname)". Here are my fields:

PeoplePicker - Datacardvalue5 Text - Datacardvalue6

Thank you!

1 Answer 1

0

Technically this formula meets your requirements:

Trim(
    $"{Last(
        Split(
            First(
                Split(
                    DataCardValue5.Selected.DisplayName,
                    "("
                )
            ).Value,
            ","
        )
    ).Value} {First(
        Split(
            First(
                Split(
                    DataCardValue5.Selected.DisplayName,
                    "("
                )
            ).Value,
            ","
        )
    ).Value}"
)

However, I would suggest that it is prone to failure. If there are edge cases where a user has a bracket or comma in their name, it would absolutely break.

My recommendation would be to add the Office365Users or AzureAD connector to your app, and use a formula something like this for your text field:

With(
    {tmpUser: Office365Users.UserProfileV2(Last(Split(DataCardValue5.Selected.Claims,"|")).Value)},
    $"{tmpUser.givenName} {tmpUser.surname}"
)
2
  • Thank you for the response. Unfortunately the People picker field won't ever technically have a Selected value, because that field has a DefaultSelectedItems formula that automatically displays a name based on another People field. So the first formula you listed. When I enter that formula, the Text field remains blank unless I manually select a user from that People field. The second formula gives me an error that I haven't seen before: The function UserProfileV2 has an invalid value for parameter "id".
    – Chris
    Sep 14, 2023 at 13:30
  • I might be making this harder than it has to be. Basically I have a Project dropdown for the user to select. I then have a People field that displays the Project Director associated with that selected project - {Value: ComboBox2.Selected.DisplayName} (in defaultselecteditems). This data won't write to Sharepoint when I submit for some reason. So I added two text fields, one for the Project Director's name, and the other for Email. Problem is when I use - ComboBox2.Selected.DisplayName for the new text field, it displays it as Shoemaker, Chris (companyname)
    – Chris
    Sep 14, 2023 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.