CMAL Query - Jsom

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();
					         '<FieldRef Name=\'Title\' />'+
					         '<Value Type=\'Text\'>another test</Value>'+
					   '<FieldRef Name=\'Title\' />'+
					   '<FieldRef Name=\'ProjectName\' />'+
					   '<FieldRef Name=\'PriorityNumber\' />'+
					   '<FieldRef Name=\'ID\' />'+
					   '<FieldRef Name=\'ParkID\' />'+
					   '<FieldRef Name=\'ProjectNumber\' />'+
		this.collListItem = oList.getItems(camlQuery);

Open in new window

Any ideas?
IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?
IsaacConnect With a Mentor SharePoint Client Side DeveloperAuthor Commented:
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>".

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

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.