EDIT Below works by replacing the success code, not sure if the best solution but it works:
success: function (data) {
if (data.d != undefined) {
$.each(data.d.results, function (index, item) {
myFirstName = item.Manager.FirstName;
myLastName = item.Manager.LastName;
myEmail = item.Manager.EMail;
myDivision = data.d.results[0].Title;
myPhone = data.d.results[0].PhoneNumber;
myJobTitle = data.d.results[0].JobTitle;
i++;
});
}
I'm trying to get information from People or Group column and assign that value to a variable but I keep getting the error alert. How do you pass the value to a variable?
var requestUri = webAbsUrl + "/_api/web/Lists/getByTitle('Organization')/Items?$\
filter=JobTitle eq 'Deputy Director'&$\
select=Division, Branch, Section, PhoneNumber, JobTitle, Manager/EMail, Manager/FirstName, Manager/LastName&$\
expand=Manager/Id";
var ajaxOrg = $.ajax({
url: requestUri,
async: false,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
countAjaxOrg = data.d.results.length;
if(countAjaxOrg > 0) {
myJobTitle = data.d.results[0].JobTitle;
myPhone = data.d.results[0].PhoneNumber;
myFirstName = data.d.results[0].Manager/FirstName;
myLastName = data.d.results[0].Manager/LastName;
myEmail = data.d.results[0].Manager/EMail;
myDivision = data.d.results[0].Division;
}
},
error: function (data) { alert("Failed to load your profile."); }
});