D365 FINANCE AND SUPPLY CHAIN ( F&O) : ADDING CUSTOM FIELDS ON CREATE PRODUCT FORM VIA EXTENSION FRAMEWORK APPROACH

 If you have added new fields in products table via extension, then their are high chances that you will also be asked to add them on the standard create product dialog.

Initially it may look like a simple task to add 2 fields on a form but when you will start developing and will have a look inside the form design you will notice that there is no data source on this form design and hence you cannot just add the fields by drag and drop feature.

No Datasource in the form design

Upon technical analysis , you will find that there is a method named createData2Controls() which basically populates a container with details of which controls on the form are mapped to which fields of the tables and then under the method writeMoreFields(), the container is read and the fields are assigned value based on the mappings present in the container.

Below is how we can use extension framework approach to add new fields to the form and add the mapping in the container.

  • Add new fields to Invent table. In my case I added 2 new fields.
  • Create extension of the EcoresProductCreate form and add unbounded controls on the form design. Set Auto declaration as True.
  • Create a new extension class and decorate it with attribute [ExtensionOf(formStr(EcoResProductCreate))].
  • In the new class , extend the method createdata2Controls() to add the mapping of your new fields on the table extension with the form unbounded controls . Below is the sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[ExtensionOf(formStr(EcoResProductCreate))]
final class XYZ_EcoResProductCreate_Extension
{
    protected void createData2Controls()
    {
        next createData2Controls();
 
        data2Controls = conIns(data2Controls,
                                conLen(data2Controls) + 1,
                                [tableStr(InventTable), [[fieldNum(InventTable, YourFieldName1), formControlStr(EcoResProductCreate, YourControlName1)]]]);
 
        data2Controls = conIns(data2Controls,
                                conLen(data2Controls) + 1,
                                [tableStr(InventTable), [[fieldNum(InventTable, YourFieldName2), formControlStr(EcoResProductCreate, YourControlName2)]]]);
 
    }
 
}

After this build the project area and run the product create process and the values will flow to the inventTable.

Hope this helps if you are trying to figure out how to use extension framework to feed the value of new controls to the table.

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++