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
    };
  • Oh I haven´t seen that you open the pop-up from the other pop-up! Does anything work when you call you own pop-up from a regular position in the Form?

    If yes, than you interfere with the other popup. I assume you have a "close dialog" function somewhere. But it doesn´t closes your dialog, but the Aras one. In this case your callback is bypassed.

    As far as I remember you have to explicitly close your dialog within the callback:

    topWindow.ArasModules.Dialog.show('iframe', params).promise.then(function(res) {

      parent.args.dialog.close();

  • How can a callback be called if the dialog doesn't close first?I tried your way but it does not go to the callback if we remove dialog.close() on save changes button which I have on my popup.I have tried adding a check on the formId of the dialog if it matches than only close it but it is also of no use.

  • I have tried using a different form on the click of a button the results are same.On a regular form it behaves accordingly.

  • Hi,

    out of interest I made a quick test by myself and it just worked fine. I used a standard Form call:

    Setup like this:

    Used code:

    var topWnd = aras.getMostTopWindowWithAras(window);
    topWnd = topWnd.main || topWnd;

    // Get form params
    var params = {
    title: 'Do something',
    formId: "30A3Exxxx", 
    aras: aras,
    dialogWidth: 1200, // set width int
    dialogHeight: 600, // set height int
    content: 'ShowFormAsADialog.html'
    };

    // Logic performed when dialog is closed
    var callback = function(res)
    {
    if(!res) // user closed dialog
    {
    aras.AlertWarning("Aborted");
    return;
    }
    return aras.AlertSuccess("Something was finished: " + res);
    };

    // Call form in dialog
    topWnd.ArasModules.MaximazableDialog.show("iframe", params).promise.then(callback);

  • My previous post referred to a some other use case of mine where I used multiple intersecting dialogs. In this case Innovator mixed up the callbacks cause I had overwritten the top window with another top window. Seems not be a problem here.. 

  • topWnd.main solved some of my problems.Now the cancel button doesnt close the QuickEdit.But when I add a relationship and it goes to a search dialog,then when the searchDialog for that related item gets closed my quickEdit also closes but my editor dialog remains open.

  • I assume you use something like this to close the form: parent.args.dialog.close();

    But there are two dialogs opened, so Innovator probably mix them up. I am sure it could be solved, but requires some investigation. 

    Well, why providing a Cancel button at all? You don´t need it, the X does the same job in this use case :-).

  • yeah I copied what was done for Part AMl Editor.The cancel button just works fine on my form  but not the cancel button on the search dialog.The search dialog for the relationship is closed by searchArguments.dialog.close(returnValue) in searchDialog.js file which is causing the problem now which is the only problem I have now with the functionality.

Reply
  • yeah I copied what was done for Part AMl Editor.The cancel button just works fine on my form  but not the cancel button on the search dialog.The search dialog for the relationship is closed by searchArguments.dialog.close(returnValue) in searchDialog.js file which is causing the problem now which is the only problem I have now with the functionality.

Children
No Data