0

I am trying to retrieve choice values from a lookup field in SharePoint 2013 using REST API.

PFB the code:

$.ajax({ url: _spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/GetByTitle('Test')/fields?$filter=EntityPropertyName eq 'Category'", type: "GET", headers: { "accept": "application/json;odata=verbose", }, success: function (data) { $scope.choices=data.d.results[0].Choices.results; alert(); }, error: function (error) { alert(JSON.stringify(error)); } }); 

This works fine for a normal choice field but doesnt work with Lookup field. Any solution?

Thanks, Dheeraj

1 Answer 1

1

Use Expand option to retrieve Lookup column values.

_api/web/lists/getbytitle('project')/items?$select=Client/Name,ClientId,Name,Id&$expand=Client 

In above example, Client is lookup column.

Refer this.

2
  • can we remove duplicates from the obtained object? Commented Jul 5, 2018 at 5:02
  • Yes, take output field values in array and remove duplicate using javascript OR use jQuery.unique() using jquery. use this link for example stackoverflow.com/questions/9229645/… Commented Jul 5, 2018 at 5:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.