0

i have a small requirement, where in i am pulling in a lot of data from List A to List B through Rest API. but i am stuck at one place where in i am not able to pull in lookup value in List B.

Hope you guys can help me out.

0

You need to use the &$expand=[Column internalname] and the &$Select=[Column internalname]/Id url parameter to get the Id of the lookup item, if you need the text value from the lookup use /Title instead of /Id.

I have a lookup to a list, the column name in list which contains the lookup is "Sync", so my REST call is like this:

/_api/web/lists(guid'1B51700E-D95D-46C5-9B9B-1386CCCC07DB')/items?$select=Title,Sync/Id&$expand=Sync

This returns the value from the column "Titel"and the id of the lookup column "Sync".

  • Hi , i am using this query 'url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists(guid'xyz')/items?$select=CP_x0020_Should_x0020_Cost_x0020,Program_x0020_Name_x003a_BU_x002/Title,Planned_x0020_Model_x0020_Close,Actual_x0020_Model_x0020_Close,SC_x0020_Team_x0020_Leader/Title&$filter=SC_x0020_Team_x0020_Leader/Title eq '"+employeeName+"'&$expand=SC_x0020_Team_x0020_Leader/Id,Program_x0020_Name_x003a_BU_x002", ' where in Program_x0020_Name_x003a_BU_x002 is the lookup column. Can you help me with this query itself? – jayant khushalani Jun 4 '19 at 5:22
  • From what I can see the query is just slightly off here: &$expand=SC_x0020_Team_x0020_Leader/Id,Program_x0020_Name_x003a_BU_x002 <-- you don't want the "/Id". You only need to tell which fields you want to expand. – Morten K Jun 4 '19 at 6:30
  • still did not work. – jayant khushalani Jun 5 '19 at 6:28
  • I assume the xyz is a placeholder in the above? Did you try it in the browser? – Morten K Jun 6 '19 at 5:32
  • yup i did but it did not work – jayant khushalani Jun 6 '19 at 6:04
0

You can use the below call to expand columns

/_api/web/lists(guid'<guid>')/items?$select=Title,LookupField1/FieldToBeExpanded1,LookupField2/FieldToBeExpanded2&$expand=LookupField1,LookupField2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.