AnsweredAssumed Answered

CAML Query

Question asked by shibu on May 24, 2016
Latest reply on May 27, 2016 by olampl11

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")

}

Outcomes