I have a list "List1" having following fields

Department : Single line of text

HOD : Person or group

There is another list called "List2" with following fields

FacultyName : Single line of text

Dept : Lookup ("Department" column of "List1")

HOD : Person or Group

My query is how to auto-populate HOD field in "List2" based on the "Dept" lookup selection.

It should fetch value from corresponding HOD field of "List1".

I am using SharePoint online.

Please help me out here. Thanks in advance.

  • I have updated the code. Did you try it? Commented Apr 19, 2018 at 9:22
  • Thanks JoannaW_MSTF for the answer. It worked. But there is slight change in requirement. There won't be group, instead multiple values will be present in the HOD field. Can you tell how to retrieve multiple values from person field?
    – sandeep
    Commented Apr 25, 2018 at 6:01
  • You need to iterate the HOD values and get each one person, such as ListItem.get_item("HOD")[i].get_lookupValue(). You can refer to stackoverflow.com/questions/22694749/…. For the new requirement, you can post a new thread as this thread is old. Accept the answer if it is helpful for the original requirement in this thread. Commented Apr 25, 2018 at 7:32

1 Answer 1


Try adding the following script to the from. It will auto-populate the People Picker column based on the lookup column.

<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script language="javascript">

$(document).ready(function () {
// the lookup field in the new form
 var IssueIDField= $("select[title='Dept']");
 IssueIDField.change(function () {

var ListItem;
function Populate() {
 var IssID = $("select[title='Dept']").val();
 var clientContext = new SP.ClientContext.get_current();
 var IssueList = clientContext.get_web().get_lists().getByTitle('cl01');
 ListItem = IssueList.getItemById(IssID);

function Succed(sender, args) {

var context = SP.ClientContext.get_current();
var web = context.get_web();
var user = web.ensureUser(ListItem.get_item("HOD").get_lookupValue());

// Get People Field
var form = $("table[class='ms-formtable']");
var userField = form.find("input[id$='HOD_17d85e7c-80fe-4131-8b50-c5d456fdd449_$ClientPeoplePicker_EditorInput']").get(0);
var peoplepicker = SPClientPeoplePicker.PickerObjectFromSubElement(userField);
// clear people Picker
while (peoplepicker.TotalUserCount > 0) {

context.executeQueryAsync(function () {
    //execute successfully
    //this is a user field
    // Set the People field
    var loginName = user.get_loginName();
}, function (sender, args) {
    //execute fail, so it isn't user field, it may be a group
    var collGroup = context.get_web().get_siteGroups();
    //get the people group via Id
    var oGroup = collGroup.getByName(ListItem.get_item("HOD").get_lookupValue());
        //execute successfully
        //this is a group field
        function () {
            // Set the People field
            var loginName = oGroup.get_loginName();
         //execute fail, it is neither user nor group
        function (sender, args) {
            contoso.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
function Failed(sender, args) {
 console.log('Error. ' + args.get_message() + '\n' + args.get_stackTrace());

Change the 'cl01' to your 'List1'. And change 'HOD_17d85e7c-80fe-4131-8b50-c5d456fdd449_$ClientPeoplePicker_EditorInput' to the id of your HOD column in 'List2'.

Use F12 to check the id of the element.

enter image description here

Refer to Auto-populate list form fields based on lookup selection in SharePoint.

  • Thank you, It works. Can you please tell me how to apply the same solution in case of "Group". (Above solution works if the value is the name of a person, but now I am asking for groups. )
    – sandeep
    Commented Apr 17, 2018 at 9:47
  • I updated the code. It also works for group. Commented Apr 18, 2018 at 2:59
  • sharepoint.stackexchange.com/questions/240888/… @JoannaW_MSTF This is my new question for Multiple Person or group values fetching. Please answer to it. Thanks in advance
    – sandeep
    Commented Apr 30, 2018 at 7:15

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.