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 :-). 

  • And When I directly cancel the new popup it executes the same behaviour so the code inside the callback is not a problem I believe.I have tried the approach as the article suggested but it leads to the same result.I have reduced code to a minimum in callback.It looks like this now:

    var callback = {
        
        oncancel: function(dialogWrapper) {
            //debugger;
            var save = dialogWrapper.result.save;
            var ids = dialogWrapper.result.ids;
            if(save === '1')
            {
                

                var predecessorKeyedNames = ids.join();
                document.thisItem.setProperty("_predecessor",predecessorKeyedNames);
                handleItemChange("_predecessor",predecessorKeyedNames);
            }
            document.getElementsByName("sort_order")[0].getElementsByTagName("input")[0].focus();
         } // on cancel
    };
Reply
  • And When I directly cancel the new popup it executes the same behaviour so the code inside the callback is not a problem I believe.I have tried the approach as the article suggested but it leads to the same result.I have reduced code to a minimum in callback.It looks like this now:

    var callback = {
        
        oncancel: function(dialogWrapper) {
            //debugger;
            var save = dialogWrapper.result.save;
            var ids = dialogWrapper.result.ids;
            if(save === '1')
            {
                

                var predecessorKeyedNames = ids.join();
                document.thisItem.setProperty("_predecessor",predecessorKeyedNames);
                handleItemChange("_predecessor",predecessorKeyedNames);
            }
            document.getElementsByName("sort_order")[0].getElementsByTagName("input")[0].focus();
         } // on cancel
    };
Children