Pages

Tuesday, July 30, 2013

Minor bug with base journal posting framework and fix

This is a bit of a frustrating bug that took some time to figure out.  This bug occurs when you are trying to fork to different journal transaction forms.  You will see it most likely when you click the "lines" button and nothing happens after the first click, and you don't know why.

An example of forking to different transaction forms can be seen from the production journals located at AOT\Forms\ProdJournalTable, where depending on your journal type, a different ProdJournalTrans* form is launched.

The bug/logic failure is located at Classes\JournalFormTable\fieldModifiedJournalNameIdPost(), and it only happens when you create a new record, select your journal name, and click on "lines" without saving.

Essentially what happens is the JournalTableData object is instantiated inside the JournalFormTable with a blank record, but the blank journal type enum is 0, which is also the first enum.  So later on, when the controls are trying to be initiated, it will set the menu item for the "Lines" button based on what your *JournalStatic\menuItemStrLines returns.  And that will return whatever the default 0 enum is.

The quick fix is, in your [Table_ds].JournalNameId\modified method, the standard code is this:

void modified()
{
    super();

    journalFormTable.fieldModifiedJournalNameIdPost();
}

You can just call the datasourceActivePre() method to reinitialize the JournalTableData's JournalTable after the correct journal type is filled as seen below:

void modified()
{
    super();

    journalFormTable.datasourceActivePre();
   
    journalFormTable.fieldModifiedJournalNameIdPost();
}

I'm guessing that very few people will come across this bug, but hopefully it helps someone.