Saturday 30 July 2011

How to use caml query in javascript\ecmascript Client object model - Sharepoint 2010


You can use CAML query with javascript\ecmascript Client object model  by using  SP.camlQuery class. Here is an example for you

var query = '‘<View><Query><Where><Eq><FieldRef Name=”Title” /><Value Type="Text">test
title</Value></Eq></Where> </Query><ViewFields><FieldRef Name=”Title” /></ViewFields></View>';
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(query);
allItems = list.getItems(camlQuery);
context.load(allItems);

context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));

enjoy!

Ads by Google

No comments:

Post a Comment