Omar El-Anis – 365 Developer

My experiences with SharePoint, Flows, PowerApps, JavaScript and all of the other lovely web technologies out there!

Uncategorised

Populate PeoplePicker with current logged in user in SharePoint 2013 with jQuery

Use the following jQuery code to populate a people picker field on a SharePoint form using jQuery and the CurrentContext object within a browser session

var loginName = _spPageContextInfo.userLoginName; //get login name form current session in browser
var pplPckr = $("span[data-displayname='Requested by'] .sp-peoplepicker-editorInput")[0]; // adapt this to any query selector to point to the input field with the class "sp-peoplepicker-editorInput"
var peoplepicker = SPClientPeoplePicker.PickerObjectFromSubElement(pplPckr) // Use SPClientPeoplePicker to get the actual picker object
peoplepicker.AddUserKeys(loginName); // Add the user login name to the key table to resolve the user

3 COMMENTS

  1. Dear manager/s of spdeveloper.co.uk

    I enjoy browsing through your website and even have it bookmarked.

    I would like to contribute by submitting a free guest post. I have a few topics in mind that are closely related to your website’s content. If you are open for collaboration, do let me know so I can get them forwarded to you.

    Kind Regards,
    Emily.

  2. Hello,

    I sent you a message earlier, but I have not received a response from you yet.

    So, I am highly interested in writing an article for your website. I have a few topics in mind that are closely related to your website’s content. If you are open for collaboration, do let me know so I can get them forwarded to you.

    Please reply back to emilylopes5@outlook.com since my Gmail account may still be unconnected.

    Kind Regards,
    Emily.

    • Hi Emily,

      Thank you for your comment and apologies for the delay in responding, I get a lot of spam emails!

      Can you advise what type of content you are writing? Always open to putting out new content to help others!

      Thanks,

      SP Admin

LEAVE A RESPONSE

Your email address will not be published. Required fields are marked *