Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

API JSOM not works

$
0
0

Hello

I'm studying newapps and api jsom,howeverI can notreturn theitems on the listthat already existson the site.When loadeditemsdid notreturn anyitem.Whatam I doing wrong?Below is the code

function defaultViewModel() {

    var self = this;
    self.message = ko.observable();
    self.loadContract = function () {

        self.context = new SP.ClientContext(hostUrl);
        self.web = self.context.get_web();
        self.contracts = ko.observableArray();
        var list = self.web.get_lists().getByTitle('Contrato');
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><RowLimit>10</RowLimit></View>');
        self.items = list.getItems(new SP.CamlQuery.createAllItemsQuery());
        self.context.load(self.items);
        self.context.executeQueryAsync(
        Function.createDelegate(self, self.onGetContractSuccess),
        Function.createDelegate(self, self.onGetContractNameFail)
        );
    }
    self.onGetContractSuccess = function (event, args) {
        var items = self.items.getEnumerator();

        while (items.moveNext()) {

            var item = items.get_current().get_fieldValues();
            self.contracts.push(
            {
                title: item.Title
                
            });
        }
    }
    self.onGetContractNameFail = function (sender, args) {
        self.message('Failed to get user name. Error:' + args.get_message());
    }
    self.loadContract();
}


Stephany Henrique de Almeida Batista



Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>