Posts

Showing posts with the label REST

SharePoint 2013 REST API Query Items with cross site lookup column

Recently, I had to query items using SharePoint 2013 Rest API (/api/web/lists/getbytitle('')/items).  The problem that makes it hard is that it has a lookup column (Product) that looks up the items in a list from another web.  The typical $filter statement (/_api/web/lists/getbytitle('Pages')/items?$select=Title,Id&$filter=Product eq 1) doesn't work. After searching online and a few trial/error, I got it working by using /_api/web/lists/getbytitle('Pages')/items?$select=Title,Id,ProductId&$filter=Product eq 1 The ProductId field is automatically added to the list by SharePoint when you have a lookup field.  You have to $select that ProductId and then you can filter the Product field.  It's weird but it works.

SharePoint with Angular

I have been working on a SharePoint Intranet project that uses AngularJS. Here is some code sample for using Angular with SharePoint.  The sample code below basically is: Getting a items from a list Searching for items with Title containing "Test" Display the results from the list and search onto the page I have the following files appFactory.js - for handling the services call to SharePoint using both JSOM and REST app.js - the main application logic (including a custom directive) list.html - the html template for my directive The files contain are pasted below. ***appFactory.js********************************* var spServices = angular.module('spServices', []); //Factory with SharePoint call using JSOM spServices.factory('SPRestSearchFactory', ['$resource',   function ($resource) {       return $resource(_spPageContextInfo.siteAbsoluteUrl + "/_api/search/query/:searchtext", { searchtext: '@querytext' }, {   ...