2

I am developing a Share-point Application in O365. Will it be possible to use web-part in online premise or only app part can only be used.

Following is the code I have used. I am getting the Access Denied when using the same code inside web-part, but when using app-part this is working.

function GetListItems() {
    var ctx = new SP.ClientContext.get_current();
    var targetList = ctx.get_web().get_lists().getById(SP.ListOperation.Selection.getSelectedList());
    var query = SP.CamlQuery.createAllItemsQuery();

    var queryResults = targetList.getItems(query);
    ctx.load(queryResults);

    ctx.executeQueryAsync(function getDocsAllItemsSuccess(sender, args) {
            var array = [];
            array.push(['Country', 'Sale']);
            var listEnumerator = queryResults.getEnumerator();
            while (listEnumerator.moveNext()) {
                array.push([listEnumerator.get_current().get_item("Title"), listEnumerator.get_current().get_item("Sales")]);
            }               
        },
        function getDocsAllItemsFailure(sender, args) {
            alert('Failed to get list items. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
        });
}
1
  • These need to be separate questions, #1 you need to expand in greater detail, #2 needs to be phrased in a manner that isn't opinion based. – Eric Alexander Aug 22 '16 at 3:35

Your Answer

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

Browse other questions tagged or ask your own question.