Oct 19, 2023

TABLE FIELD MODIFIED EVENT HANDLER IN D365 FO

Below is an example to trigger a function on field modified event 

1) Go to AssetTable --> Events --> onModifiedField 

2) Right click on the onModifiedField  --> Copy event handler

3) Create a new class and paste the copied eventhandler signature

4

 Class My_AssetTable_EventHandler

    /// <summary>

    /// 

    /// </summary>

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

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

    [DataEventHandler(tableStr(AssetTable), DataEventType::ModifiedField)]

    public static void AssetTable_onModifiedField(Common sender, DataEventArgs e)

    {

       

        ModifyFieldEventArgs fieldEvent = e as DataEventArgs;

        AssetTable assetTable = sender as AssetTable;

        FieldId         fieldId = fieldEvent.parmFieldId();

        

        switch(fieldId)

        {

            case(fieldNum(AssetTable, Name)):

                if(assetTable.AdditionalName)

                {                    

                    if(Box::yesNo("Do you want to update Asset additional description with same value",DialogButton::No))

                    {

                        assetTable.AdditionalName = assetTable.Name;

                    }                    

                }

                else

                {

                    assetTable.AdditionalName = assetTable.Name;

                }

            break;

            default:

                break;

        }

    }

}

No comments: