Multiple-Column Lookup value is represented as an array of SP.FieldLookupValue objects
.
How to read multi-valued lookup field using SharePoint 2013 REST
Assume Employee
list with a multi-valued lookup field Departments
Then the query: /_api/web/lists/getbytitle('<list title>')/items
returns an array of lookup ids, for example:
getListItems(_spPageContextInfo.webAbsoluteUrl,'','Employees',
function(items){
if(items.length > 0)
console.log(items[0].DepartmentsId); //returns an array [LookupId1, LookupId1 .. LookupIdN]
},
function(error){
console.log(error.responseText);
});
The query:
/_api/web/lists/getbytitle('Employees')/items?$select=Departments/Title,Departments/Id&$expand=Departments
returns projected Departments array of objects as shown below:
getListItems(_spPageContextInfo.webAbsoluteUrl,'?$select=Departments/Title,Departments/Id&$expand=Departments','Employees',
function(items){
if(items.length > 0)
if(items[0].Departments.results.length > 0) {
console.log(items[0].Departments.results[0].Title);
console.log(items[0].Departments.results[0].Id);
}
},
function(error){
console.log(error.responseText);
});
SharePoint 2013 REST read list items function:
function getListItems(url, query, listName, success, failure) {
$.ajax({
url: url + "/_api/web/lists/getbytitle('" + listName + "')/items" + query,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
success(data.d.results);
},
error: function (data) {
failure(data);
}
});
}