Sunday, 20 February 2022

onValidatingField TableEventHandler in D365 F&O

class DDDInventJournalNameTableEventHandler

{

    [DataEventHandler(tableStr(InventJournalName), DataEventType::ValidatingField)]

    public static void InventJournalName_onValidatingField(Common sender, DataEventArgs e)

    {

        ValidateFieldEventArgs  validateFieldEventArgs = e as ValidateFieldEventArgs;

        InventJournalName       inventJournalName = sender as InventJournalName;

        boolean                 ret = validateFieldEventArgs.parmValidateResult();

        LedgerJournalName       ledgerJournalName;

        #Define.defaultGeneraljournal('Please provide the valid default general journal.')

         if(ret)

        {

            switch(validateFieldEventArgs.parmFieldId())

            {

                case fieldNum(InventJournalName,DDDDefaultGeneralJournal):

                    select firstonly ledgerJournalName

                        where ledgerJournalName.JournalName == inventJournalName.DDDDefaultGeneralJournal

                        && ledgerJournalName.DDDBudget == NoYes::Yes;

                    if (!ledgerJournalName.RecId && inventJournalName.DDDDefaultGeneralJournal)

                    {

                        ret = checkFailed(#defaultGeneraljournal);

                    }

                    break;

            }

        }

        if (!ret)

        {

            validateFieldEventArgs.parmValidateResult(false);

        }

    }

No comments:

Post a Comment

DefaultDimension in d365 FO X++

 Navigate to PurchTable methods you can find with DefaultDimension this.DefaultDimension = this.mergeDimension(this.getDefaultDimension(),th...