Forum Discussion
Automatically fill a single text column in Lists by the value of a Person Field column
- Jun 13, 2023
Femke11 If you just want to show the email address in the list view, you can easily do it using JSON formatting like:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "[$PersonGroupCol.email]" }
Where PersonGroupCol is internal name of person or group field. You can get the internal name of your person or group column by following this article: How to find the Internal name of columns in SharePoint Online?
You can read more information about this approach in my answer given at: Get Email from user and enter into SharePoint list field
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
I'm so sorry - I will test it more thoroughly in the future before I give a response...
In List A
In my additional request I only wanted to retrieve the email-addresses which work fine with the JSON formatting (suggestion from ganeshsanap ). It's quick and I don't have to press a button. I type a name in a 'Person or Group' column and the email address is automatically placed in a single line of text column (with JSON formatting as shown above).
In List B
Now there is another List and I want get the 'Name-field' and the 'Email-field' from List A (that is actually a Person or Group column) via a Lookup column. Person Fields are not available for Lookup columns. So, in List A I added another single line of text column and with JSON formatting I retrieved the name.
BUT.... the columns with JSON formatting (in List A) will not show in List B... (the columns that I've made with the help of @RobElliott do show up though).
I've tried making another single line of text column in List A where I show the content of the formatted column, but I'm not experienced enough to get that working. Don't even know if calculated columns will show up in Lookup columns?
My additional question
Is there a way that I retrieve info (like email and name) without having to press a button, but will also show up in the Lookup in List B?
Femke11 You cannot use person or group columns in the calculated column formula. So, you cannot get user name from person field using calculated columns.
Above JSON I provided in my response only works for showing the email in list view. It is not saving the actual email/name value in the column. So, you cannot use it in lookup columns.
If you want the actual value to be stored in the column, you will have to use the Power automate flow on item creation/update. Follow this response: Automatically fill a single text column in Lists by the value of a Person Field column
Let me know if you are stuck while creating such power automate flow, I will try to show some examples in that case.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- Femke11Jun 14, 2023Copper Contributor
Thanks again! Totally clear to me now. And the flow works perfectly (both: with the button, as RobElliot explained, and with the 'When an item is created or modified'-trigger).
For people who are interested in the flow, here's a screenshot:
- ganeshsanapJun 14, 2023MVP
Femke11 You may not require Get item and Get user profile actions in your flow.
Try passing Person field Email output from trigger outputs directly in update item action.
Also, as I and RobElliott mentioned in our above responses, this might lead to infinite flow run loop as you are using update item action inside flow which triggers on item creation as well as item update.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- Femke11Jun 14, 2023Copper Contributor
This works (passing Person field Email output from trigger outputs directly in update item action):
Thanks again both of you!
- RobElliottJun 14, 2023Silver ContributorCareful, that's going to end up with the infinite loop; the flow will trigger constantly.