Showing posts with label Ajax. Show all posts
Showing posts with label Ajax. Show all posts

Saturday 1 June 2013

Retrieving lookup list columns using REST SharePoint 2013 API

Problem:  I have 2 related SharePoint lists: 1) Question and a Child (linked) list 2)Comment.  I need to perform an JS call using jQuery to retrieve a specific comment item and I need to also know the Title field from it's related parent list (Question).  The 2 lists are shown below.  The post Creating related lists for SP Hosted Apps using VS2012 show you how to do this.

Resolution:
Open you browser  and check the query works:
http://dev-d8f436fea03755.apps.dev.local/SPHostedApp/_api/web/lists/getByTitle('Comment')/items(1)?$select=*,Question/Title&$expand=Question/Title
(replace the url)

jQuery Ajax code I used to call the REST API is shown below:

The ajax call is made in the document.Ready() method call.