Solved

CMAL Query - Jsom

Posted on 2016-10-17
1
107 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

739 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