“The Art of Debugging” – Tip 5 – Dynamics Anywhere Form Trace

The Dynamics Anywhere  mobile solution for AX is a great solution. As an aid to designing and developing new functionality and to aid the process of issue resolution I have developed a small tool that can be used to quickly identify the form trace for an active user. The tool displays the list of forms that the user has navigated through including their currently displayed form.

The tool works by interrogating the session table (Table: D2MFWApplicationSession) , the form stack table (Table: D2MFWFormInstanceStack) and the application instance table (Table: D2MFWApplicationInstanceTable).

This then produces output such as that shown by the following screenshot: –

 

image

In this example the user MJ has navigated through the form GRScanLocation, then onto form GCScanPurchId and is now at form GRListPurchId.

 

The following is a sample of the code used: –

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
static void DisplayDAWFormTrace(Args _args)
{
    D2MFWFormInstanceStack  D2MFWFormInstanceStack;
    D2MFWFormInstanceTable  D2MFWFormInstanceTable;
    D2MFWApplicationSession D2MFWApplicationSession;
    D2MFWApplicationInstanceTable D2MFWApplicationInstanceTable;
    Dialog                  dialog;
    DialogField             dlgUserId;
 
    D2MFWUserId             UserId;
 
    dialog = new Dialog(Select DAW User”);
 
    dlgUserId = dialog.addFieldValue(extendedTypeStr(D2MFWUserID),"");
 
    dialog.run();
 
    if (dialog.closedOk())
    {
        UserId = dlgUserId.value();
 
        setPrefix(strFmt("Form trace for user ‘%1’", UserId));
 
        select firstOnly * from D2MFWApplicationSession
        where D2MFWApplicationSession.userid == UserId;
 
        while select * from D2MFWFormInstanceStack
        order by LineNum
        join * from D2MFWApplicationInstanceTable
        where D2MFWApplicationInstanceTable.applicationInstanceID == D2MFWFormInstanceStack.applicationInstanceID &&
              D2MFWApplicationInstanceTable.sessionID             == D2MFWApplicationSession.sessionID
        {
            select firstonly * from D2MFWFormInstanceTable
            where D2MFWFormInstanceTable.formInstanceID        == D2MFWFormInstanceStack.formInstanceID &&
                  D2MFWFormInstanceTable.applicationInstanceID == D2MFWFormInstanceStack.applicationInstanceID;
 
            info(strFmt('%1', D2MFWFormInstanceTable.formConfigID));
 
        }
 
        select firstOnly * from D2MFWApplicationInstanceTable
        where D2MFWApplicationInstanceTable.sessionID             == D2MFWApplicationSession.sessionID;
 
        select firstonly * from D2MFWFormInstanceTable
        where D2MFWFormInstanceTable.formInstanceID          == D2MFWApplicationInstanceTable.currentformInstanceID &&
              D2MFWFormInstanceTable.applicationInstanceID   == D2MFWApplicationInstanceTable.applicationInstanceID;
 
        info(strFmt('%1', D2MFWFormInstanceTable.formConfigID));
 
    }
 
}