[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CMAL Query - Jsom

Posted on 2016-10-17
1
Medium Priority
?
145 Views
Last Modified: 2016-10-17
Hi All,

I am using JSOM to try and retrieve values from SharePoint and filtering by using caml.
Unfortunately, all results are returned ignoring the caml query.  I did use u2u query builder to generate the caml query code and it works in the u2u environment so not sure why it's not working in my code.

var clientContext = new SP.ClientContext();
		var oList = clientContext.get_web().get_lists().getByTitle('ParkFundingForm');
		
		var camlQuery = new SP.CamlQuery();
			camlQuery.set_viewXml(
					   '<Query>'+
					   '<Where>'+
					      '<Eq>'+
					         '<FieldRef Name=\'Title\' />'+
					         '<Value Type=\'Text\'>another test</Value>'+
					      '</Eq>'+
					   '</Where>'+
					'</Query>'+
					'<ViewFields>'+
					   '<FieldRef Name=\'Title\' />'+
					   '<FieldRef Name=\'ProjectName\' />'+
					   '<FieldRef Name=\'PriorityNumber\' />'+
					   '<FieldRef Name=\'ID\' />'+
					   '<FieldRef Name=\'ParkID\' />'+
					   '<FieldRef Name=\'ProjectNumber\' />'+
					'</ViewFields>'
			   );
	  
		this.collListItem = oList.getItems(camlQuery);
		
		clientContext.load(collListItem);

Open in new window


Any ideas?
0
Comment
Question by:Isaac
1 Comment
 
LVL 5

Accepted Solution

by:
Isaac earned 0 total points
ID: 41847088
I figured it out and I won't delete just in case someone else has the same issue.  I surrounded the query with "<View></View>".

<View><Query>"+
					   "<Where>"+
					      "<Eq>"+
					         "<FieldRef Name='Title' />"+
					         "<Value Type='Text'>another test</Value>"+
					      "</Eq>"+
					   "</Where>"+
					"</Query>"+
					"<ViewFields>"+
					   "<FieldRef Name='Title' />"+
					   "<FieldRef Name='ProjectName' />"+
					   "<FieldRef Name='PriorityNumber' />"+
					   "<FieldRef Name='ID' />"+
					   "<FieldRef Name='ParkID' />"+
					   "<FieldRef Name='ProjectNumber' />"+
					"</ViewFields></View>

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question