When I open my list form that time I want to fetch all the data from the contact list and store in my javascript array.

enter image description here


To retrieve items to array using JSOM , you should use loadQuery instead of load.

function Getallitems() { 

    var ctx = new SP.ClientContext(appWebUrl);
    var List = ctx.get_web().get_lists().getByTitle('your list name');
    var cquery = SP.CamlQuery.createAllItemsQuery();

    var query = List.getItems(cquery);
    var allitems = ctx.loadQuery(query);
    ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded(sender, args) { alert("Succeed");}

function onQueryFailed(sender, args) {

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

allitems is now working as array.

  • Thank you for reply where can i write this code? i am using SharePoint Designer.
    – Admin
    Sep 1 '16 at 14:00
  • you are welcome, but should you tell me what you are doing using Designer to can help you how to use it, where it's client side code that you can use it at control event like onclick event at button Sep 1 '16 at 14:11
  • I want to bind the contract list record to my drop down when page load also i want to bind only those record which related to select the customer. customer type is external data.
    – Admin
    Sep 1 '16 at 14:17
  • I want to implement logic like this prnt.sc/ccxmlg
    – Admin
    Sep 1 '16 at 14:21
  • Should we continue to this room because your question needs more details chat.stackexchange.com/rooms/44476/… Sep 1 '16 at 14:30

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.