how do I get the user account login id from a lookup column people field?

  • 19 September 2017
  • 2 replies
  • 43 views

Badge +1

If I do a lookup() to another list to retrieve a Person field - in this case branch manager, I get a value

4661#;John Doe

How do I get the account name etc to set a people picker field on the form?


2 replies

Badge +9

Set "Show field" attribute to "Account" in SharePoint list column settings for the Person field to get account by lookup function.

If You need also Name attribute in SharePoint list, You can create a list workflow to set one field based on the value of the other field when item is created or modified.

Badge +1

So I tried that - and it does work - however for some reason it looks like no value is returned for users who have not signed into the site collection. So I ended up using the SP REST API to load the data

NWF$.ajax({
        url: url + "/_api/web/lists/getbytitle('" + listname + "')/items(" + id + ")",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function(data) {
            // Returning the results
            var person = data.d.BranchManager;
            var obj = JSON.parse(person);

            var ins = new NF.PeoplePickerApi('#' + peoplePickerCntrl);
           
            ins.search(obj.ID).done(function(data) {
                ins.clear();
                ins.add(data[0]);

            });
        },
        error: function(data) {
            alert("Failed");
        }
    });

Reply