0

I try to take the elemtens in a list where the field "Mise à jour parc" is set to "No" with the boolean type.

My field 'Mise à jour parc" has for db name for sharepoint "Mise_x0020__x00e0__x0020_jour_x0"

Here is my query code with the query:

var collListItemToBeUpdatedReventeMaj = "";
var numOccurrencesMajRevente = 0;
var enumeratorRevente;
function getItemsToBeUpdatedReventeMaj() //this function called on button click to get ID's
{
     collListItemToBeUpdatedReventeMaj = "";
     var clientContext = new SP.ClientContext.get_current();
     var oList = clientContext.get_web().get_lists().getByTitle('Matériel revente finale');
     var camlQueryReventeMaj = new SP.CamlQuery();
     camlQueryReventeMaj.set_viewXml("<View> <Query> <Where> <Eq> <FieldRef Name='Mise_x0020__x00e0__x0020_jour_x0'> <Value Type='Boolean'>0</Value> </FieldRef> </Eq> </Where> </Query> </View> ");
     collListItemToBeUpdatedReventeMaj = oList.getItems(camlQueryReventeMaj);
     clientContext.load(collListItemToBeUpdatedReventeMaj);
     clientContext.executeQueryAsync(getItemsToBeUpdatedSuccess1ReventeMaj, getItemsToBeUpdatedFailed1ReventeMaj);
}
function getItemsToBeUpdatedSuccess1ReventeMaj()
{

    numOccurrencesMajRevente = collListItemToBeUpdatedReventeMaj.get_count();
    setValue2();            
}
function getItemsToBeUpdatedFailed1ReventeMaj(sender, args)
{
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}



    function setValue2() {

        $("#revente_count").text(numOccurrencesMajRevente).toString();
    }

I always go in the failed. I tried :

"<View> <Query> <Where> <Eq> <FieldRef Name='Mise_x0020__x00e0__x0020_jour_x0'> <Value Type='Boolean'>False</Value> </FieldRef> </Eq> </Where> </Query> </View> "

"<View> <Query> <Where> <Eq> <FieldRef Name='Mise_x0020__x00e0__x0020_jour_x0'> <Value Type='Integer'>0</Value> </FieldRef> </Eq> </Where> </Query> </View> "

"<View> <Query> <Where> <Eq> <FieldRef Name='Mise_x0020__x00e0__x0020_jour_x0'> <Value Type='Text'>No</Value> </FieldRef> </Eq> </Where> </Query> </View> "

"<View> <Query> <Where> <Eq> <FieldRef Name='Mise_x0020__x00e0__x0020_jour_x0'> <Value Type='Bool'>0</Value> </FieldRef> </Eq> </Where> </Query> </View> "

I'm sure FieldRef is good because without the Value, I have the number for all items.

An idea?

2

The CAML would look like:

<Where>
      <Eq>
         <FieldRef Name='booleanField' />
         <Value Type='Boolean'>0</Value>
      </Eq>    
</Where>

If you are going to be building a lot of CAML queries, I'd highly recommend picking up the CAML Designer from http://www.biwug.be/resources.

  • Thank you, my mistake was with the FieldRef that I closed after the value – Jey10 May 3 '16 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.