Use related fields of Person and group type in several columns in a sharepoint item

Félix Martins 20 Reputation points
2023-09-27T09:37:42.0366667+00:00

I created a sharepoint list with a column "Person or Group" type with the value of "Name" field. For example, I need to create another column in this list with the field "Email" from the "Person or Group" type and related with the value of "Name" field.

How I can do this?

Thank you.

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

Accepted answer
  1. Emily Du-MSFT 51,846 Reputation points Microsoft External Staff
    2023-09-28T07:30:45.89+00:00

    Here are steps:

    1.Create a "Person or Group" column named "people".

    2.Create a "Single line of text" column named "email".

    3.Click the "email" column -> Column settings -> Format this column -> Advanced mode -> Use following JSON codes.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "[$people.email]"
    }
    

    Result:

    enter image description here


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Emily Du-MSFT 51,846 Reputation points Microsoft External Staff
    2023-09-29T06:25:24.67+00:00

    In the SharePoint server 2013, you could use PowerShell to achieve this.

    1.Create a "Person or Group" column named "people".

    2.Create a "Single line of text" column named "email".

    3.Run following PowerShell.

    Note: You should replace SiteURL and ListName with your own.

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
     
    #Configuration Variables
    $SiteURL = "http://sp13/sites/emily"
    $ListName = "testlist"               
    $FieldName="people"
      
    #Get site and List objects
    $web = Get-SPWeb $SiteURL
    $list= $web.lists[$listName]
    
     
    #Iterate through each row in the list
    foreach ($Item in $list.Items)
    {
        #Get the People picker field value
        $AssignedTo = New-Object Microsoft.Sharepoint.SPFieldUserValue($Web,$Item[$FieldName])
        $email=$AssignedTo.User.Email
        $Item["email"] = "$email"
        $Item.Update()
    }
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.