I have a column WhoRead(type: "Person or Group") and an onclick event. When I click on an item I want to fill the column "WhoRead" with the current user email. I already have the code to get the current user email.

var context = new SP.ClientContext.get_current();
this.website = context.get_web();
this.currentUser = website.get_currentUser();

Can Someone help me?


Try below one may be it will help you

$(document).ready(function () 
    var userEmail = _spPageContextInfo.userLoginName;
    var PickerTitle = "WhoRead";
    setTimeout(function () 
        $('input[title="' + PickerTitle + '"]').val(userEmail).attr('size', 40);
        $('div[title="' + PickerTitle + '"] span.ms-helperText').hide();

        // Select the target user field from the dictionary of user fields on the page.
        var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[$('[title="' + PickerTitle + '"]')[0].id];

        // Resolve the user using the value set in the input field.
  • Thank you for the answer! I have an item on my homepage and when an user click it is supposed to fill the column "WhoRead" from the list where it fills that column with every email that also clicked the item. I don't know if the code you sent was suppose to do that... – KmDroid Nov 21 '18 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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