The D365 F&O has an out of box function named “Add products“, If developer develops an item-base table and wants to copy this function for this table. The following codes.
Code Example
To begin with, we need to extend the standard system class to implement a custom strategy for loading default items in the ‘Add Productions’ dialog. When the user selects one or multiple lines and clicks the ‘Add Productions’ button, the dialog should automatically prefill the item field(s) based on the selected records.
Secondly, we need to use a Chain of Command (CoC) extension on the createProducts method to implement the logic for adding items to the custom table.
select firstonly product from inventTable where inventTable.ItemId == MTable.ItemId join ecoResProduct where ecoResProduct.RecId == inventTable.Product;