Solved

CMAL Query - Jsom

Posted on 2016-10-17
1
39 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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now