I'developped an apps for sharepoint online. This apps propose to diffuser uploaded document under all library subsite. In first i retrieve all sub site then load needed library and finally. I do some executeQueryAsync but after some calls my executeQueryAsync are no more fired.

function RemoveDocumentsLinks() {
WaitMessage.show("Diffusing documents", "Removing links...");

// We retrive the current web title, that we have used as prefix for the links names
var WebTitle = sourceWeb.get_title();

// We will loop upon all documents that need to be "undiffused"
//var DocsEnumerator = selectedDocuments.getEnumerator();

//while (DocsEnumeratorRemove.moveNext()) {
if (cptRemoveFolder == 0) {
    CurrentItemRemove = DocsEnumeratorRemove.get_current();

if (CurrentItemRemove != undefined) {
    var DocName = CurrentItemRemove.get_item("FileLeafRef");

    var sLinkName = WebTitle + "-" + DocName;
    console.log("RemoveDocumentsLinks = " + cptRemoveFolder);
    //$.each(Destinations, function (i, Destination) {
    var Destination = Destinations[cptRemoveLib];
    var destinationWeb = Destination.List.get_parentWeb();
    if ((cptRemoveFolder) % 2 == 0) {
        // Links are created for either "Public" or "Shared to department" modes. We remove both, and we don't catch the error that would occur if the link does no exists.
        var publicLinkToDeleteUrl = Destination.List.get_rootFolder().get_serverRelativeUrl() + "/Public/" + sLinkName + ".aspx";
        var PublicLinkToDelete = destinationWeb.getFileByServerRelativeUrl(publicLinkToDeleteUrl);
        context.executeQueryAsync(onRemoveDocumentsLinksSuccessOrFailure, onRemoveDocumentsLinksSuccessOrFailure);
    else {
        var departmentLinkToDeleteUrl = Destination.List.get_rootFolder().get_serverRelativeUrl() + "/Department/" + sLinkName + ".aspx";
        var DepartmentLinkToDelete = destinationWeb.getFileByServerRelativeUrl(departmentLinkToDeleteUrl);
        context.executeQueryAsync(onRemoveDocumentsLinksSuccessOrFailure, onRemoveDocumentsLinksSuccessOrFailure);

        // As there is noting more to do, we will wait for all the deletion processes to complete


I write a log and put a breakpoint in onRemoveDocumentsLinksSuccessOrFailure function but it passes never in and i go correctly till the executequeryasync.

Why a call souldn't be fired?

  • Without trying to re-create your environment I can only guess that either cptRemoveFolder == 0 or CurrentItemRemove != undefined is false and your if statement with the executeQueryAsync calls is never being entered. Use the browser dev tools and place a breakpoint before each call to context.executeQueryAsync then see where you actually make it to in your code, if you don't make it to either breakpoint place another back up in your first conditional block -- in chrome dev tools you can dynamically break by inserting the command debugger into your code – John-M May 11 '15 at 14:15
  • Hi, i've already debug with developer tool and out a breakpoint. It goes till the executequeryasync but after it never goes inside the success or failure method. What could make this issue? – user1898765 May 11 '15 at 19:48

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.