Lately we run into the problem when after creating workflow configuration for any process we are unable to save it. After we click button "Save and close" Dynamics AX asks if we want to activate workflow immediately. Regardless from the choice we make, the saving process does not finish, the form does not close, but the configuration is also not saved.

Digng further into it, I found out that code is interrupted ret = modelEditorControl.SaveAndClose(); in line of anClose of form WorkflowEditorHost

public boolean canClose()
{
    boolean ret;

    ret = super();

    if (saveOnClose)
    {
        ret = modelEditorControl.SaveAndClose();
    }

    return ret;
}

Because during execution of modelEditorControl.SaveAndClose(); exception is raised and not caught in X++ the code is interrupted and nothing happens. This is why the form is neither close nor workflow configuration is saved.

We can simply change the code to catch the error following way:

 

public boolean canClose()
{
    boolean ret;

    System.Exception netExcepn;

 

    ret = super();

     if (saveOnClose)
     {
        try
        {
            ret = modelEditorControl.SaveAndClose();
        }
         catch (Exception::Error)
        {
            info("Caught 'Exception::Error'.");
        }
        catch (Exception::CLRError)
        {
            info("Caught 'Exception::CLRError'.");
            netExcepn = CLRInterop::getLastException();
            info(netExcepn.ToString());
        }

     }

    return ret;
}

 

Disclaimer:
This programming example is for illustration purposes only. Microsoft disclaims all warranties and conditions with regard to use of the programming example for other purposes. Microsoft shall not, at any time, be liable for any special, direct, indirect or consequential damages, whether in an action of contract, negligence or other action arising out of or in connection with the use or performance of the programming example. Nothing herein should be construed as constituting any kind of warranty.

 

After change in the code we were able to see that there is indeed exception raised. Unfortunately the exception message was not so useful but it made us to look into Workflow event log on AOS machine (Under Application and Services Logs > Microsoft Dynamics AX Workflow) and there we found following error:

Exception thrown in  : Workflow configuration Method not found: 'Dynamics.Ax.Application.NumberSeq Dynamics.Ax.Application.NumberSeq.newGetNum(Dynamics.Ax.Application.NumberSequenceReference, Boolean, Boolean, Boolean, Boolean)'.

Looking into NumberSeq class we could see that one of the method was changed (the method signature). Although after all the incremental CIL was generated it seems the signature was not updated in CIL. After following steps issue was solved:

1. Compiling forward class NumberSeq

2. Generating again incremental CIL