cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

CAML Query

Am using CAML query to extract values from the formMaster list using multiple filters. But the code written in JS returns all the values from the list instead of matching value. Please refer my below code. Could you please help me to resolve.

var pollSP;

var itemColl ;

NWF.FormFiller.Events.RegisterAfterReady(function () {

    pollSP = setInterval(checkSPLoad, 500);

});

function checkSPLoad() {

    if (clientContext) {

        window.clearInterval(pollSP);

        onSPLoad();

    }

}

function onSPLoad() {

     //Our code must come here

var contextClient = new SP.ClientContext.get_current();

var web = clientContext.get_web();

var camlQuery = new SP.CamlQuery();

 

var objFC = NWF$("#" + jsFC);   // Handle of form category

var objFN = NWF$("#" + jsFN);  // Handle of form name

objFC.change(function(){ 

var contextClient = new SP.ClientContext.get_current();

    var lstFM =   clientContext.get_web().get_lists().getByTitle("formMaster");

 

  var q = "<view><query><where><And> <Eq><FieldRef Name='category' /><value Type='Text'>ERP</value></Eq><Eq><FieldRef Name='status' /><value Type='Text'>Active</value></Eq></And> </where></query></view>";

    camlQuery.set_viewXml(q);

itemColl = lstFM.getItems(camlQuery);

clientContext.load(itemColl);

clientContext.executeQueryAsync(Function.createDelegate(this, onItemsLoadSuccess), Function.createDelegate(this, onQueryFailed));

 

});

}

function onItemsLoadSuccess(sender, args) {

  var listItemInfo = '';

var listItemEnumerator = itemColl.getEnumerator();

while (listItemEnumerator .moveNext()) {

var listItem =listItemEnumerator.get_current();

listItemInfo += '\nID: ' + listItem.get_item('formName') +

'\nStatus: ' + listItem.get_item('status')

}

alert(listItemInfo.toString());}

function onQueryFailed(sender, args) {

   alert("Failed")

}

Tags (2)
0 Kudos
Reply
1 Reply
olampl11
Nintex Newbie

Re: CAML Query

Do you know this codeplex project​ , very useful tool for creating and testing CAML querys

So it is much easier to find and fix the bug

Regard Oliver

Reply