AX / D365FO – Get datasource from a Form extension class

At Form Level [ExtensionOf(formStr(SalesTable))] final class KSSalesTableFrm_Extension { public int active() { FormRun formRun = this as FormRun; //get any datasource from the base form FormDataSource salesLine_ds = formRun.datasource(FormDatasourceStr(SalesTable,SalesLine)); SalesLine salesLine = salesLine_ds.Cursor(); //get any formcontrol from the base form FormControl itemName= formRun.design().ControlName(FormControlStr(SalesTable, itemName)); //business Logic return next active(); } } At FormDataSource level [ExtensionOf(formDatasourceStr(SalesTable, … Continue reading AX / D365FO – Get datasource from a Form extension class

AX – D365FO – Modify methods of a Data Entity through extension – X++

In this example, DataEntityToExtend is the data entity and validateDelete and validateWrite are methods that can be wrapped in the data entity. [ExtensionOf(tableStr(DataEntityToExtend))] final class DataEntityToExtend_Extension { public boolean validateDelete() { boolean ret; //... ret = next validateDelete(); //... return ret; } public boolean validateWrite() { boolean ret; //... ret = next validateWrite(); //... return ret; } }

AX – D365FO – Modify methods of tables through extension – X++

In this example, TableToExtend is the table and delete, canSubmitToWorkflow, and caption are methods that can be wrapped in the table. [ExtensionOf(tablestr(TableToExtend))] final class TableToExtend_Extension { public void delete() { next delete(); //... } public boolean canSubmitToWorkflow(str _workflowType) { boolean ret; //... ret = next canSubmitToWorkflow(_workflowType); //... return ret; } public str caption() { str ret; //... ret = next caption(); … Continue reading AX – D365FO – Modify methods of tables through extension – X++

AX – D365FO – Add methods to tables through extension – X++

You first create a new class in the extension model. This class will augment the InventTable table, and enable access to the table's fields and methods in a manner that is easy to read and understand. It's important that you choose the correct name for your augmentation class. This name must be unique across all … Continue reading AX – D365FO – Add methods to tables through extension – X++

AX – D365FO – Ho w to add a default value in a field and hide it in a Form grid

Result to obtain go to "Vendor collaboration" --> "Vendor nformation" -->"Certifications" A form will be opened "VendTableVendExternal"and a grid will appear We want to set a default value for the field "Certifying organization" and hide it to the user. How to do this in X++ : Set Default value to the field First create the … Continue reading AX – D365FO – Ho w to add a default value in a field and hide it in a Form grid

D365FO – AX – Update Data Entity Target Entity fields with X++

Imagine you want to set the value of a field of the Target Entity of a Data Entity with X ++ code You have to create an extension class that extends the data Entity, extends "mapEntityToDataSource" method and add your code inside. [ExtensionOf(tableStr(PurchPurchaseOrderHeaderV2Entity))] //Extends Data Entity final class Al0PurchPurchaseOrderHeaderV2Entity_Extension { public void mapEntityToDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext … Continue reading D365FO – AX – Update Data Entity Target Entity fields with X++

D365FO – AX – Extends Data Entity method using Chain of Command

Extending a data entity with Chain of Command is the same as extending a table. Create an extension class, use "ExtensionOf" attribute, call method and use Chain of command. [ExtensionOf(tableStr(PurchPurchaseOrderHeaderV2Entity))] final class Al0PurchPurchaseOrderHeaderV2Entity_Extension { /// <summary> /// Extension method /// </summary> /// <param name = "_entityCtx"></param> /// <param name = "_dataSourceCtx"></param> public void mapDataSourceToEntity(DataEntityRuntimeContext _entityCtx, … Continue reading D365FO – AX – Extends Data Entity method using Chain of Command

AX – D365FFO – Class extension model in X++

This article describes the new class extension model in X++. Because over-layering is a very intrusive feature, we recommend that you not use it. The alternative to over-layering is extension. Extension lets you extend existing artifacts in a new model. Extensions are easier to maintain, but the amount of extension that can be done during … Continue reading AX – D365FFO – Class extension model in X++

AX – D365FFO – Write extensible enums

An enumeration (enum) is made extensible by setting the following enum properties: Is Extensible = TrueUseEnumValue = No If you set these properties, downstream implementors can extend the enum with more elements. The values of the elements are determined at deployment time and won't be identical across systems. However, the following behavior is ensured: Data … Continue reading AX – D365FFO – Write extensible enums

AX – D365FO – Modify existing fields in a table through extension

To modify properties on an existing field in a table, you must first create an extension for the table. You can modify the following properties: LabelHelp textCountry Region CodesExtended Data Type – You can select only extended data types (EDTs) that are derived from the currently selected EDT. The lookup in the property sheet is filtered … Continue reading AX – D365FO – Modify existing fields in a table through extension