Thursday, 19 November 2020

Display inventory dimensions dynamically in D365

The table must have the field InventDimId and it must have a relation with InventDim. Image 2. Create a new Form. My form has two data sources, InventDimDisplay and InventDim (required) and a grid. Image 3. Set the InventDim data source properties to: Image REPORT THIS AD 4. On form Design, create a new Grid and move the ItemId to your grid and then create a new Group and then set the properties below: Image 5. On class declaration add the following piece of code: 1 2 3 4 5 public class FormRun extends ObjectRun { // Declare the class InventDimCtrl_Frm_EditDimensions InventDimCtrl_Frm_EditDimensions inventDimFormSetup; } 6. Now, create a new method in form. 1 2 3 4 public InventDimCtrl_Frm_EditDimensions inventDimSetupObject() { return inventDimFormSetup; } 7. Override the form’s method Init. 1 2 3 4 5 6 public void init() { super(); // This method will be used to show default fields at form startup element.updateDesign(InventDimFormDesignUpdate::Init); } 8. Create a new method, this method is responsible to show the Inventory Controls. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 void updateDesign(InventDimFormDesignUpdate mode) { InventDimParm inventDimParmVisible; switch (mode) { // Form Init case InventDimFormDesignUpdate::Init : if (!inventDimFormSetup) inventDimFormSetup = InventDimCtrl_Frm_EditDimensions::newFromForm(element); inventDimFormSetup.parmSkipOnHandLookUp( true); // Use the methods on InventDimParm // to set which dimensions to show when form is initialized inventdimparmvisible.inventsiteidflag = true; inventdimparmvisible.InventLocationIdFlag = true; inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmVisible); // Datasource Active case InventDimFormDesignUpdate::Active : inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(InventDimDisplay.ItemId)); //InventDimDisplay is the datasource name. inventDimFormSetup.formSetControls( true); break; // Datasource Field change case InventDimFormDesignUpdate::FieldChange : inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(InventDimDisplay.ItemId)); //InventDimDisplay is the datasource name. InventDim.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled()); // InventDim is referring to datasource name inventDimFormSetup.formSetControls( true); break; default : throw error(strFmt ("@SYS54195", funcName())); } } 9. We have to create a method on data source to update our table InventDimId and use the method Active to refresh the controls. Override Data source’s method Active. 1 2 3 4 5 6 7 public int active() { int ret; ret = super(); element.updateDesign(InventDimFormDesignUpdate::Active); return ret; } 10. Now, override the method Modified for ItemId field in your data source. 1 2 3 4 5 6 7 public void modified() { super(); element.updateDesign(InventDimFormDesignUpdate::FieldChange); InventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled()); } 11. We have to create a MenuItemButton to call the Display Dimension form where the user can select which dimensions he want to display. Set the following properties: MenuItemType: Display MenuItemName: InventDimParmFixed 12. By the end of this tutorial, your form should look like this. Image 13. The results: Image

1 comment:

  1. Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks

    ReplyDelete