0

I have a custom code to get data from a second list, this list returns some columns, but this code is getting only 10 values even tho the list have a lot more than that. I got this code from a microsoft website some time ago and I modified it.

Code:

function retrieveListItems() {

  var clientContext = new SP.ClientContext(siteUrl);
  var oList = clientContext.get_web().get_lists().getByTitle('Adicionar favorecidos');

  var camlQuery = new SP.CamlQuery();
  camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
  this.collListItem = oList.getItems(camlQuery);

  clientContext.load(collListItem);

  clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededed), Function.createDelegate(this, this.onQueryFaileded));

}

function onQuerySucceededed(sender, args) {


  var listItemInfo = '';
  var arrayCNPJ = '';
  var agencia = '';
  var contaBancaria = '';
  var chaveDoBanco = '';
  var valorLiquido = '';
  var valorBruto = '';


  var listItemEnumerator = collListItem.getEnumerator();

  while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    listItemInfo += ";" + oListItem.get_item('Title');
    arrayCNPJ += ";" + oListItem.get_item('CNPJ');
    agencia += ";" + oListItem.get_item('Agencia');
    conta += ";" + oListItem.get_item('ContaBancaria');
    chaveDoBanco += ";" + oListItem.get_item('ChaveDoBanco');
  }

  window.arrayItem = listItemInfo.split(";");
  window.arrayCNPJFormatado = arrayCNPJ.split(";");
  window.agenciawindow = agencia.split(";");
  window.contawindow = conta.split(";");
  window.chaveDoBancoWindow = chaveDoBanco.split(";");


  $('#favorecidoSelect').select2();
  $('.selectMaterialize').formSelect();

  $('#favorecidoSelect').on('contentChanged', function () {
    $(this).select2();
  });

  for (var i = 0; i < arrayItem.length; i++) {
    $('#favorecidoSelect').append('<option value=' + i + '>' + arrayItem[i] + '</option>');
    $("#favorecidoSelect").trigger('contentChanged');
  }

  //alert(listItemInfo.toString());
}

function onQueryFaileded(sender, args) {

  alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
2

You're only getting 10 because you're only asking for 10.

<RowLimit>10</RowLimit>

  • 2
    didn't notice that, really dumb mistake. I got this code from microsoft and I really don't know how it works.Well, thank you and happy new year! – Eddie Dec 28 '18 at 16:57

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.