SharePoint People/Group Picker - returning properties

SharePoint People/Group Picker - returning properties

TamrasTamras Posts: 12Questions: 5Answers: 0

without datatables, working code looks like this:

var requestUri = webAbsUrl + "/_api/web/Lists/getByTitle('Directory')/Items?$\
filter=JobTitle eq 'Deputy Director'&$\
select=Phone, JobTitle, Name/EMail, Name/FirstName, Name/LastName, Photo&$\
expand=Name/Id";

            var ajaxOrg = $.ajax({
                url: requestUri,
                async: false,  //pass value outside of ajax
                method: "GET",
                headers: { "Accept": "application/json; odata=verbose" },
                success: function (data) {
                    if (data.d != undefined) {
                        $.each(data.d.results, function (index, item) {
                            myFirstName = item.Name.FirstName;
                            myLastName = item.Name.LastName;
                            myEmail = item.Name.EMail;
                            myPhone = data.d.results[0].Phone;
                            myJobTitle = data.d.results[0].JobTitle;
                            myPhotoURL = data.d.results[0].Photo.Url;   
                            i++;
                        });
                    }
                },
                error: function (data) { alert("Failed to load your profile."); }
            });

With datatables, I can't figure out how to pull the properties from the Name column which is of People/Group field type. I want to pull the email, first, and last names from the NAME column.

Using below returns [object Object] in column rather than displaying the FirstName
"aoColumns": [
{ "mData": "Name",
"fnRender":function(mData) {
if(obj.aData.Name.results != undefined) {
$.each(obj.aData.Name.results, function(index,item) {
return item.FirstName;
});
}
}
},
{ "mData": "Phone"}
],
});

Answers

  • TamrasTamras Posts: 12Questions: 5Answers: 0

    found the answer from one of the responses from this post

This discussion has been closed.