Thursday, 27 October 2011

Sharepoint 2010 ecmascript get only approved items


Today I had to get all the approved items from a list using ecmascript. The simple soltuion was a CAMl query with value of 16.

So here is the CAML -

var query = '<view><query><where><eq><fieldref Name="Approved" />
<value Type="Text">16</Value></Eq></Where></Query>
<viewfields><fieldref Name="Title" /></ViewFields></View>';
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(query);
var allItems = list.getItems(camlQuery);
context.load(allItems);

16 is the number for Approved status

Ads by Google

No comments:

Post a Comment