none
SharePoint Online - executeQueryAsync "Access denied You do not have the pemission to perform this action or access this resource" RRS feed

  • Question

  • Hi there,

    the platform is SharePoint Online

    i had encountered problem on executing JSOM executeQueryAsync on my scripting, to retrieve record from list then populate to label field, the list has only 5 records. the event fires upon dropdown changed

    when i logging as SharePoint Admin, i have no error at all

    while another user just granted with "Contribute" rights will hit error upon executeQueryAsync, it said "Access denied You do not have the pemission to perform this action or access this resource"

    Image

    however, if i re-fire again the same dropdown change event then it is no issue at all

    even i had granted the user with "Full Control" right but it still hitting the same error


    script

    function onGetProdDescSucceeded() {
       var deferred = $.Deferred();
    
       var Code = $('#ct01_prodcode').val();
       var ctx22 = new SP.ClientContext.get_current();
       var listproddesc = ctx22.get_web().get_lists().getByTitle(RMProductListName);
       var camlQuery = new SP.CamlQuery();
    
       camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + Code + "</Value></Eq></Where></Query></View>");
       var materialItems = listproddesc.getItems(camlQuery);
    
       ctx22.load(materialItems);
       console.log('before excecuteQueryAsync');
       ctx22.executeQueryAsync(
                        Function.createDelegate(this, function () { deferred.resolve(materialItems); }),
                        Function.createDelegate(this, function (sender, args) { deferred.reject(sender, args); })
                    );
       console.log('before promise');
       return deferred.promise();
    }



    • Edited by Split fire Wednesday, April 5, 2017 2:03 PM
    Wednesday, April 5, 2017 2:02 PM

All replies

  • Could you please try this one...

    function onGetProdDescSucceeded() { var deferred = $.Deferred(); var Code = $('#ct01_prodcode').val(); var ctx22 = new SP.ClientContext.get_current(); var listproddesc = ctx22.get_web().get_lists().getByTitle(RMProductListName); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + Code + "</Value></Eq></Where></Query></View>"); var materialItems = listproddesc.getItems(camlQuery); ctx22.load(materialItems); console.log('before excecuteQueryAsync');

    var test=false; ctx22.executeQueryAsync( Function.createDelegate(function() {

    deferred.resolve(materialItems);

    }), Function.createDelegate(function (sender, args) {

    console.log(args.get_message());

    deferred.reject(test);

    }) ); console.log('before promise'); return deferred.promise(); }

    Wednesday, April 5, 2017 3:08 PM
  • i now hit error on apply

    Uncaught TypeError: Cannot read property 'apply' of undefined
        at Array.<anonymous> (ScriptResource.axd?d=e5QDhBuaLB10RFcUFapffgyXvFuY_Am0vjG24oZOjusKOLdgWcQvVie10oHzrB_JXRW6pGtJxtdyTV…:5)
        at ScriptResource.axd?d=e5QDhBuaLB10RFcUFapffgyXvFuY_Am0vjG24oZOjusKOLdgWcQvVie10oHzrB_JXRW6pGtJxtdyTV…:5
        at SP.ClientRequest.$3I_0 (sp.runtime.js:2)
        at Array.<anonymous> (ScriptResource.axd?d=e5QDhBuaLB10RFcUFapffgyXvFuY_Am0vjG24oZOjusKOLdgWcQvVie10oHzrB_JXRW6pGtJxtdyTV…:5)
        at ScriptResource.axd?d=e5QDhBuaLB10RFcUFapffgyXvFuY_Am0vjG24oZOjusKOLdgWcQvVie10oHzrB_JXRW6pGtJxtdyTV…:5
        at Sys.Net.WebRequest.completed (ScriptResource.axd?d=e5QDhBuaLB10RFcUFapffgyXvFuY_Am0vjG24oZOjusKOLdgWcQvVie10oHzrB_JXRW6pGtJxtdyTV…:5)
        at XMLHttpRequest._onReadyStateChange (ScriptResource.axd?d=e5QDhBuaLB10RFcUFapffgyXvFuY_Am0vjG24oZOjusKOLdgWcQvVie10oHzrB_JXRW6pGtJxtdyTV…:5)

    Thursday, April 6, 2017 8:19 AM
  • Hi,

    I suggest you provide the complete code in use if possible or provide more information about your scenario, which should make the issue easier to be researched.

    If you want to access SharePoint 2013 data from add-ins, we can use cross-domain library to achieve it.

    https://msdn.microsoft.com/en-us/library/office/fp179927.aspx

    To get list items, we can also use jQuery Ajax with REST API to achieve it. To make synchronization, we can set async: false in $.ajax call.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, April 6, 2017 8:44 AM
    Moderator
  • Please try to execute code using Deferred object and make sure that all required SharePoint js loaded, and share complete code to get more idea.


    Thanks, Amit Kumar, LinkedIn Profile ** My Blog


    Thursday, April 6, 2017 1:20 PM