Callback not working properly if I dont have debugger in my javascript code

I have added a popup on button click on the mpp_OperationQuickEdit Form which opens form with a single relationship which I have created.It works like the 'Launch AML Editor' action on MCOs.I have added a save changes button which adds or remove relationships based on relationship added or removed.Then a callback function is provided.the relationships are added or removed successfully but the problem is that the callback works fine if I have put debugger in my javascript code otherwise it just closes both the forms the new popup and the quickEdit form.What could be the problem?

Parents
  • Sounds like your callback function not really works. Callbacks/promises/async-await is used for asynchronous stuff when Innovator shall wait for another client task to be completed. 

    Regular code is executed synchronous. So it can happen that your Form is closing before something in between was finished. When using the debugger you slow down the whole process and you give Innovator more time for execution. -->That´s why your code works with debugger enabled.

    I am not sure, but as far as I remember the AML Editor doesn´t use async calls at all?!? Classical Form callback looks something like this: community.aras.com/.../tech-tip-calling-a-date-dialog-from-a-method

    Or you execute too much time consuming stuff inside the callback. This would require further callbacks :-). 

  • Yes it does not have a callback.I have added timeouts on callback as well as save button click but it was of no use.I have only 1 debugger that is on show dialog button.Can it be because the quick edit form is also a popup?I am getting a relationship items and setting a property on the quick edit form on the callback.My code looks like this:

    debugger;
    var inn = document.thisItem.getInnovator();
    var opItem = document.thisItem;
    var query = new Item("mpp_Operation""get");
    query.setID(document.thisItem.getID());
    query = query.apply();
    var param = aras.newObject();
    param.title = "Predecessor Editor for Operation " + opItem.getProperty("sort_order");
    param.formId = "A0637ABC383446F1A84D6CEB4D2CC574"//Predecessor Editor Form
    param.aras = aras;
    param.item = query;
    var options = {
        dialogWidth: 1100,
        dialogHeight: 460,
        resizable: 'no'
    };

    // This will be called after the dialog is closed
    var callback = {
        
        oncancel: function(dialogWrapper) {
            //debugger;
            var save = dialogWrapper.result.save;
            if(save === '1')
            {
                var predecessorIds = [];
    pr = document.thisItem;
                var mppOperationID = document.thisItem.getID();
                var query = "<AML>"+
                            "<Item type='abc' action='get' select='id,related_id,sort_order'>"+
                                "<source_id>"+mppOperationID+"</source_id>"+
                            "</Item>"+
                            "</AML>";
                var predecessorItems = inn.applyAML(query);
                var count = predecessorItems.getItemCount();
                if(count > 0)
                {
                    for (var j = 0; j < count; j++)
                    {
                        var currentPredessorItem = predecessorItems.getItemByIndex(j).getRelatedItem();
                        var keyedName = currentPredessorItem.getProperty("keyed_name","");
                        predecessorIds.push(keyedName);
                    }
                }

                var predecessorKeyedNames = predecessorIds.join();
                document.thisItem.setProperty("_predecessor",predecessorKeyedNames);
                handleItemChange("_predecessor",predecessorKeyedNames);
            }
            document.getElementsByName("sort_order")[0].getElementsByTagName("input")[0].focus();
         } // on cancel
    };
    var topWnd = top.aras.getMostTopWindowWithAras();
    var wnd = topWnd ? topWnd : window;
    //wnd.ArasModules.Dialog.show('iframe', param).promise.then(callback);
    var res = aras.modalDialogHelper.show('DefaultPopup', wnd, param, options, 'ShowFormAsADialog.html', callback);
Reply
  • Yes it does not have a callback.I have added timeouts on callback as well as save button click but it was of no use.I have only 1 debugger that is on show dialog button.Can it be because the quick edit form is also a popup?I am getting a relationship items and setting a property on the quick edit form on the callback.My code looks like this:

    debugger;
    var inn = document.thisItem.getInnovator();
    var opItem = document.thisItem;
    var query = new Item("mpp_Operation""get");
    query.setID(document.thisItem.getID());
    query = query.apply();
    var param = aras.newObject();
    param.title = "Predecessor Editor for Operation " + opItem.getProperty("sort_order");
    param.formId = "A0637ABC383446F1A84D6CEB4D2CC574"//Predecessor Editor Form
    param.aras = aras;
    param.item = query;
    var options = {
        dialogWidth: 1100,
        dialogHeight: 460,
        resizable: 'no'
    };

    // This will be called after the dialog is closed
    var callback = {
        
        oncancel: function(dialogWrapper) {
            //debugger;
            var save = dialogWrapper.result.save;
            if(save === '1')
            {
                var predecessorIds = [];
    pr = document.thisItem;
                var mppOperationID = document.thisItem.getID();
                var query = "<AML>"+
                            "<Item type='abc' action='get' select='id,related_id,sort_order'>"+
                                "<source_id>"+mppOperationID+"</source_id>"+
                            "</Item>"+
                            "</AML>";
                var predecessorItems = inn.applyAML(query);
                var count = predecessorItems.getItemCount();
                if(count > 0)
                {
                    for (var j = 0; j < count; j++)
                    {
                        var currentPredessorItem = predecessorItems.getItemByIndex(j).getRelatedItem();
                        var keyedName = currentPredessorItem.getProperty("keyed_name","");
                        predecessorIds.push(keyedName);
                    }
                }

                var predecessorKeyedNames = predecessorIds.join();
                document.thisItem.setProperty("_predecessor",predecessorKeyedNames);
                handleItemChange("_predecessor",predecessorKeyedNames);
            }
            document.getElementsByName("sort_order")[0].getElementsByTagName("input")[0].focus();
         } // on cancel
    };
    var topWnd = top.aras.getMostTopWindowWithAras();
    var wnd = topWnd ? topWnd : window;
    //wnd.ArasModules.Dialog.show('iframe', param).promise.then(callback);
    var res = aras.modalDialogHelper.show('DefaultPopup', wnd, param, options, 'ShowFormAsADialog.html', callback);
Children
No Data