Dynamics 365 FO - Table Extensions - Song Nghia - Microsoft Dynamics Partner

Song Nghia - Microsoft Dynamics Partner

Song Nghia - Microsoft Dynamics Partner

Breaking

Saturday, September 17, 2022

Dynamics 365 FO - Table Extensions

 Dynamics 365 FO - Table Extensions

Nghia Song -  Microsoft Dynamics 365 Technical Consultant

Nghia Song

Tel - WhatsApp: +84967324794

Email: songnghia.uit@gmail.com


Table extensions

You can create a table extension to extend a table's design and logic. You can add new fields, field groups, indexes, mappings and relations. You can also add new fields to existing field groups, change the label of a table field, change the Created By, Created Date Time, Modified By, Modified Date Time properties. Using table extensions, you can also change the Extended Data Type property on fields and set it to an EDT that is derived from the current EDT (This is available as of platform update 8).

In Microsoft Dynamics AX 2012, you could override the virtual methods of a table's base class to control the behavior that occurred during table operations, such as when creating, reading, updating, or deleting. In the current version, you instead use extensions to implement event handlers that are called from the base implementations of the table methods. The following table lists each table method and its events.

Published Table method

Preceding event

Succeeding event

validateWrite

ValidatingWrite

ValidatedWrite

validateDelete

ValidatingDelete

ValidatedDelete

validateField

ValidatingField

ValidatedField

validateFieldValue

ValidatingFieldValue

ValidatedFieldValue

modifiedField

ModifyingField

ModifiedField

modifiedFieldValue

ModifyingFieldValue

ModifiedFieldValue

Insert

Inserting

Inserted

Update

Updating

Updated

Delete

Deleting

Deleted

Initvalue

InitializingRecord

InitializedRecord

FinalDeleteValidation

Executed when a delete operation is performed on a table object, before the operation is committed to the underlying database table

N/A

FinalInsertValidation

Executed when an insert operation is performed on a table object, before the operation is committed to the underlying database table

N/A

FinalReadValidation

Executed when a read operation is performed on a table object.

N/A

FinalUpdateValidation

Executed when an update operation is performed on a table object, before the operation is committed to the underlying database table.

N/A

Validation events capture and return results by using the DataEventArgs parameter. The display and edit method modifiers are supported on table extensions

  1. Table event handler sample

/// <summary>

        ///

        /// </summary>

        /// <param name="args"></param>

        [PostHandlerFor(tableStr(PurchTable), tableMethodStr(PurchTable, initValue))]

        public static void PurchTable_Post_initValue(XppPrePostArgs args)

        {

            PurchTable purchTable = args.getThis() as PurchTable;

            purchTable.test_PrintNote = NoYes::Yes;

        }


        /// <summary>

        ///

        /// </summary>

        /// <param name="sender"></param>

        /// <param name="e"></param>

        [DataEventHandler(tableStr(CustInvoiceTrans), DataEventType::Inserted)]

        public static void CustInvoiceTrans_onInserted(Common sender, DataEventArgs e)

        {

            ValidateEventArgs   event       = e as ValidateEventArgs;

        CustInvoiceTrans custInvoiceTrans=sender as CustInvoiceTrans;

        SalesTable salesTable=SalesTable::find(custInvoiceTrans.salesid);

        if(salesTable.SalesStatus==SalesStatus::Invoiced )

            {

       

         //code

            }

        }

        /// <summary>

        ///

        /// </summary>

        /// <param name="args"></param>

        [PostHandlerFor(tableStr(SalesTable), tableMethodStr(SalesTable, updateBackStatus))]

        public static void SalesTable_Post_updateBackStatus(XppPrePostArgs args)

        {

            SalesTable salesTable = args.getThis();


            SalesTable salesTable = SalesTable::find(custInvoiceTrans.salesid);

            if (salesTable.SalesStatus == SalesStatus::Invoiced)

            {

                //code

            }

        }


Next: Dynamics 365 FO - Form extensions

https://www.songnghia.com/2022/09/dynamics-365-fo-form-extensions.html


NExt

No comments:

Post a Comment