Unexpected voucher number proposed when creating a new journal line after sorting the grid in a journal

Scenario:

When creating a new line in a journal after sorting the data in the grid users may see an unexpected voucher number proposed for the new line.

Resolution:

To resolve the issue 3 objects require a change (note that the affected journal will determine the Form that requires the change).

1.  \Forms\LedgerJournalTransVendInvoice\Methods\ClassDeclaration

Before:

    SOURCE #ClassDeclaration

class FormRun extends ObjectRun

{

            QueryBuildRange             ledgerJournalTransRange;

LedgerJournalEngine         ledgerJournalEngine;

            ……

 

After:

    SOURCE #ClassDeclaration

            class FormRun extends ObjectRun

            {

                RecId currentRecordForCreate;

           

                QueryBuildRange             ledgerJournalTransRange;

                LedgerJournalEngine         ledgerJournalEngine;

          ……

2. \Forms\LedgerJournalTransVendInvoice\Data Sources\LedgerJournalTrans\Methods\create()

 Before:

 

                     try

                  {

                      ledgerJournalTransEntityManager.getFormDataEventManager().beginEntityCreateEvent();

                      journalFormTrans.datasourceCreatePre();

            ……….

 

After:

 

                  try

                  {

                      if (currentRecordForCreate != 0)

                      {

                          ledgerJournalTrans_ds.findRecord(LedgerJournalTrans::findRecId(currentRecordForCreate, false));

                      }

         

                      ledgerJournalTransEntityManager.getFormDataEventManager().beginEntityCreateEvent();

                      journalFormTrans.datasourceCreatePre();

            ……….

3. \Forms\LedgerJournalTransVendInvoice\Methods\task()

 

New Method:

 

      public int task(int _taskId)

      {

          int ret;

          ;

          if (_taskId == 260)

          {

              currentRecordForCreate = ledgerJournalTrans.RecId;

          }

          ret = super(_taskId);

          return ret;

      }