cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tagustin2020
Power Participant
Power Participant

Write a LookUp Field back to SharePoint as a Person Field

Hello,

 

Matthew Devaney kindly provided a formula for the person fields in my gallery that abbreviates the name to lastname.first initial (e.g. Agustin, T.). It works great when you are pointing to a person field.

 

With(

   {UserName: Split(ThisItem.'Created By'.DisplayName, " ")},

   First(UserName).Result & " " & Left(Last(UserName).Result,1)& "."

)

 

Here is my challenge. I have a column of names that is being brought into the Gallery as a Text value, based on a LookUp so the formula above doesn’t work for that scenario. Rather than ask for help rewriting the above formula to work for a name brought in as text, I would prefer to import the name as a person field if possible.

 

Here is more context for clarification:

When a user selects a Project Number from a dropdown menu in the New Request Form, the Text property of the Program Mgr/Product Engineer label is automatically populated via the following formula. So far, so good. The information is coming over as a user name.

 

LookUp('Project List','Project Number' = ddProjectNumber.Selected.'Project Number','Project Owner'.DisplayName)

 

Here is where things go sideways. In order to write this information back to my Tool Design Support Request SharePoint list, I kept the original text input field that came with the datacard and set the Default property to: lblPMPE.Text

 

The label is visible to the user, the text field is hidden since its sole purpose is to write data back to SharePoint.

 

How should I write the text property formula for the hidden field so it is recorded back to SharePoint as a person field instead of a text field? I figure if I do it this way, I can apply Matthew's formula to the Project Owner name in my gallery. I assume that I will have to delete the single line of text column in my Tool Design Support Request SharePoint list and create a person column instead to capture this information. Can you confirm?

 

Thank you in advance for your help. Teresa

2 ACCEPTED SOLUTIONS

Accepted Solutions

@tagustin2020 

I don't believe your issue is going to be with the splitting or label contents or anything like that, my assumption is that you have a Person Column in your SharePoint list and you want that to have the person that is the Program Mgr/Product Engineer written to that column.

The Program Mgr/Product Engineer information is currently coming to you from  Lookup on 'Project List' and you state it is in a Full name format (first and last).

 

You have a label and a textinput control on your form.  The input is hidden (not visible) and the label is visible.  They both contain the name of the person you want to write to SharePoint.

 

I hope that so far the above is all accurate.

 

So, first, you need not have a separate hidden textinput control for this, you can work entirely from the Label. I will proceed as such.

 

Since you are working with a Person column in SharePoint, the key is you need the email address of the person.  So, Display names or other splitting of them is of no value in the person column.

 

I am going to assume that the 'Project List'.'Project Owner' column is a Person column as well.

 

If so, then you can simply change the Default property of your data card in your EditForm for the PM/PE column to the following:

LookUp('Project List',
       'Project Number' = ddProjectNumber.Selected.'Project Number',
       'Project Owner')

That person column in the Project List will have the proper signature for writing to SharePoint into a Person column.

 

Once you have that, you can get rid of the TextInput control that is hidden - it's not needed.

And you can have the Label Text property in your DataCard set to Parent.DisplayName

 

I hope this is clear for you - let me know if you run into bumps along the way.

 

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

@tagustin2020 

No worries, I actually took today to catch up on a slew of apps currently in the design stage.  So checking the forum is no problem.

 

So, this formula:

With({dn:Match(ThisItem.'ME Assigned'.DisplayName, "^.*\s.").FullMatch},
    If(IsBlank(dn), "Pending", dn & ".")
)

Should work perfectly for you if you are in an EditForm.  Your label is in an EditForm DataCard - correct?

To explain what it does, 

First it performs a Match on the current record of the Form (ThisItem) and the 'ME Assigned'.DisplayName with a regular expression that will return (FullMatch) the first name and the first initial of the last.  To really break that down:

^.*\s.

^ - start from the first character and match .* any number of actual characters until a \s space, then match . one character.  It's just a little cleaner that splitting and concatenating and lefting and so forth.

Now, we store that in a With variable called dn (just because we don't want to repeat in the coming if statement.

And in the If statement, we look to see if it is blank...if so, say "Pending".  If not, then display it (dn) with a "period" on the end.

 

This works just fine, so if it is not, then we need to explore more of what your scenario is.  The only thing I would think is that perhaps you are not in an Edit Form DataCard?  Or that you are not changing the correct property (should be the Text property).

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

12 REPLIES 12
RandyHayes
Super User
Super User

@tagustin2020 

Actually, the formula that @mdevaney  provided should be just as well in your Gallery. What kind of problems are you experiencing getting that to work properly?

I mention it because it will be simpler than dealing with a Person column in SharePoint.  If you can avoid using them, it is better, and I believe you are only trying to use that in order to get a previous formula to work for you - which would be better figured out than worked around.

 

If you want to proceed with the Person column in SharePoint, then the first question will be, are you submitting data via a form or through a Patch statement?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi Randy,

 

I get two errors:

 

1) Invalid use of Label1.Text

2) The function 'Split' has some invalid arguments

 

Teresa

@tagustin2020 

I don't believe your issue is going to be with the splitting or label contents or anything like that, my assumption is that you have a Person Column in your SharePoint list and you want that to have the person that is the Program Mgr/Product Engineer written to that column.

The Program Mgr/Product Engineer information is currently coming to you from  Lookup on 'Project List' and you state it is in a Full name format (first and last).

 

You have a label and a textinput control on your form.  The input is hidden (not visible) and the label is visible.  They both contain the name of the person you want to write to SharePoint.

 

I hope that so far the above is all accurate.

 

So, first, you need not have a separate hidden textinput control for this, you can work entirely from the Label. I will proceed as such.

 

Since you are working with a Person column in SharePoint, the key is you need the email address of the person.  So, Display names or other splitting of them is of no value in the person column.

 

I am going to assume that the 'Project List'.'Project Owner' column is a Person column as well.

 

If so, then you can simply change the Default property of your data card in your EditForm for the PM/PE column to the following:

LookUp('Project List',
       'Project Number' = ddProjectNumber.Selected.'Project Number',
       'Project Owner')

That person column in the Project List will have the proper signature for writing to SharePoint into a Person column.

 

Once you have that, you can get rid of the TextInput control that is hidden - it's not needed.

And you can have the Label Text property in your DataCard set to Parent.DisplayName

 

I hope this is clear for you - let me know if you run into bumps along the way.

 

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you for your help Randy. It all worked out great. I'll mark it as a solution. Can I ask you one more related question? In my gallery I have a "Mechanical Engineer" column. An ME is assigned after a request is submitted. Currently, a small dot appears if the value is blank. Can you help me write an If statement to the affect of "If this item is blank have the column field read "Pending" else fill in the name of the ME that was assigned"?

 

I tried the following, but it isn't working.

 

If(IsBlank, "pending", With(
    {UserName: Split(ThisItem.'ME Assigned'.DisplayName, " ")},
    First(UserName).Result & " " & Left(Last(UserName).Result,1)& "."
))

 

Thank you,

Teresa

@tagustin2020 

Sure thing.  I assume this is a Label in your gallery that we are talking about.  

If so, then set the Text property to:

Coalesce(ThisItem.'ME Assigned'.DisplayName, "Pending")

I'm not entirely sure why you are using the Split function to  split a display name that is separated by a space and then put it back together with the space.  Is this only so that you can have a abbreviated last name (as I see you use the Left function).

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@tagustin2020 

To add on to the previous response - if you DO want to have first and first letter of last name, you might want to just substitute the following:

Coalesce(Match(ThisItem.'ME Assigned'.DisplayName, "^.*\s.").FullMatch, "Pending")

If the period you have after the last name initial is important, then go with this:

 

With({dn:Match(ThisItem.'ME Assigned'.DisplayName, "^.*\s.").FullMatch},
    If(IsBlank(dn), "Pending", dn & ".")
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi Randy,

 

Yes, this is a label in the gallery. I'm currently using the formula shown below provided by Matthew Devaney. Not sure how to combine it with the Coalesce statement. I tried replacing the formula below with the Coalesce formula, but received the following error message: Unexpected characters. Characters lblMEAssigned.Text. The ME Assigned column is set to "person".

 

To answer your question of why the Split approach, I had told Matthew that I would like the format to be LastName, FirstInitial. (e.g. Agustin, T.). 

 

With(

   {UserName: Split(ThisItem.'ME Assigned'.DisplayName, " ")},

   First(UserName).Result & " " & Left(Last(UserName).Result,1)& "."

)

 

Thanks for all your help on a Sunday. I realize you have a life so don't feel you have to respond today if you are trying to fit in some R & R. 

 

Kind regards,

Teresa

@tagustin2020 

No worries, I actually took today to catch up on a slew of apps currently in the design stage.  So checking the forum is no problem.

 

So, this formula:

With({dn:Match(ThisItem.'ME Assigned'.DisplayName, "^.*\s.").FullMatch},
    If(IsBlank(dn), "Pending", dn & ".")
)

Should work perfectly for you if you are in an EditForm.  Your label is in an EditForm DataCard - correct?

To explain what it does, 

First it performs a Match on the current record of the Form (ThisItem) and the 'ME Assigned'.DisplayName with a regular expression that will return (FullMatch) the first name and the first initial of the last.  To really break that down:

^.*\s.

^ - start from the first character and match .* any number of actual characters until a \s space, then match . one character.  It's just a little cleaner that splitting and concatenating and lefting and so forth.

Now, we store that in a With variable called dn (just because we don't want to repeat in the coming if statement.

And in the If statement, we look to see if it is blank...if so, say "Pending".  If not, then display it (dn) with a "period" on the end.

 

This works just fine, so if it is not, then we need to explore more of what your scenario is.  The only thing I would think is that perhaps you are not in an Edit Form DataCard?  Or that you are not changing the correct property (should be the Text property).

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you Randy. You're the best! I applied this formula to the label in my gallery and it worked perfectly. I really appreciate you taking the time to explain what the formula means. I will keep it for future reference. Teresa

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!      

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Top Solution Authors
Top Kudoed Authors
Users online (3,202)