RSS

Dimension Development in DAX 365 FO

13 Feb

Dimension Development in DAX 365 FO

Types:

  1. Financial Dimension
  2. Ledger Dimension (Segmented entry Control)
  3. Ledger Dimension Account lookup Based on Account Type selection in Table
  4. Inventory Dimension display
  5. In New From, using new table
  6. In Standard form using new table (Extension)

Steps:

Financial Dimension

In Table

  1.       Add new field in table as “DefaultDimension”
  2.       Add new relation with relation table “DimensionAttributeValueSet”

Table.DefaultDimension == DimensionAttributeValueSet.RecId

In Form

  1.       Add new Tab in Form Design
  2.       Set Auto declaration property to yes for Tab control
  3. Add New control Dimension Entry Control
  4. Set Following properties
  5. DS
  6. Label (Caption Text)
  7.  view field

2. Ledger Dimension (Segmented entry Control)

In Table

  1.  Added new field in table
  2. LedgerDimension (EDT: DimensionDynamicAccount)
  3. AccountType (EDT: LedgerJournalACType) (For Dummy and set field Properties visible, AllowEdit to No)

Note: Add With relation to DimensionAttributeValueCombination table as   Table.LedgerDimension == DimensionAttributeValueCombination.RecId

In Form

  1.       Add newly created field in form design node(Form Grid Control)
  2. Auto declaration = Yes
  3. Controller class = DimensionDynamicAccountController
  4. Filter expression = %1
  5. Is Default Account = False (lookup Show Segmented Entry with dimension combination as per account structure setup)

Ledger Dimension Account lookup Based on Account Type selection in Table

In Table

  1.       Added new fields in table
  2.       AccountType (EDT: LedgerJournalACType)

              iii.      LedgerDimension (EDT: DimensionDynamicAccount)

Note: Add With relation to DimensionAttributeValueCombination table as   Table.LedgerDimension == DimensionAttributeValueCombination.RecId

In Form

  1.       Add newly created field in form design node(Form Grid Control)
  2.  Auto declaration = Yes
  3. Controller class = DimensionDynamicAccountController
  4. Account Type field = AccountType
  5. Filter expression = %1
  6. Is Default Account = True (Lookup show only Main Accounts list).
  7. Add Override method on Form Data source Field
  8. Method: Modified (Code Snippet)
  9.        Table_ds.refresh();
  10.         Add Override method on Form Design node Field

Method: Lookup (Code Snippet)

switch (Table.AccountType)

            {

                case LedgerJournalACType::Bank:

                    BankAccountTable::lookupBankAccount(this); break;

                case LedgerJournalACType::Cust:

                    CustTable::lookupCustomer(this); break;

                case LedgerJournalACType::FixedAssets:

                    AssetTable::lookupAccountNum(this); break;

                case LedgerJournalACType::Project:

                    ProjTable::lookupProjId(this, Table); break;

               case LedgerJournalACType::Vend:

                    VendTable::lookupVendor(this); break;

                default:

                    super(); break;

            }

Method: checkUserCustomLookup (Code Snippet)

boolean returnValue;

LedgerJournalACType

accountType = any2Enum(_accountTypeEnumValue);

switch (accountType)

{

case

LedgerJournalACType::Bank || LedgerJournalACType::Cust || LedgerJournalACType::FixedAssets || LedgerJournalACType::Project || LedgerJournalACType::Vend:

                                                                                                                                returnValue = true; break;

                                                                                                default:               returnValue = false; break;

                                                                                }

                                                                                return returnValue;

Inventory Dimension display

Display inventory dimensions dynamically in D365

      For New Table and New Form

  1. Create new fields in table using (InventDimId) and create relation with InventDim
  2. Add InventDim datasource in form and join (Inner Join) it with datasource which contains your item id (new Table)
  3. Create a new group under your gird. Set its datasource property to InventDim and Data group property to InventoryDimesions
  4. Add InventDimParmFixed Display menu item to your Tab->action pane menu.
  5. Write code  on form Methods

Code:

Method  Class Declaration:

//Declare variables in form class declaration

InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;

Method  inventDimSetupObject (New)

public InventDimCtrl_Frm_EditDimensions inventDimSetupObject()

{

    return inventDimFormSetup;

}

Method  init (New)

public void init()

{

    super();

    // This method will be used to show default fields at form startup

    element.updateDesign(InventDimFormDesignUpdate::Init);

}

Method  updateDesign (New)

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;

                inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmVisible);

        // Datasource Active

        case InventDimFormDesignUpdate::Active  :

            inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(<TableName>.ItemId));

inventDimFormSetup.formSetControls( true);

            break;

        // Datasource Field change

        case InventDimFormDesignUpdate::FieldChange :

            inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(<TableName>.ItemId));

            InventDim.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled()); // InventDim is referring to datasource name

            inventDimFormSetup.formSetControls( true);

            break;

        default :

            throw error(strFmt (“@SYS54195”, funcName()));

    }

}

Method a Data source Method a active (New) – (Note: which is having itemId)

public int active()

{

    int ret;

    ret = super();

    element.updateDesign(InventDimFormDesignUpdate::Active);

    return ret;

}

Method  Data source Method a Field ItemId Modified (new)

public void modified()

{

    super();

    element.updateDesign(InventDimFormDesignUpdate::FieldChange);

    InventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());

}

Open New created FORM and check the option

For New Table on Standard Form (Extension)

  1. Create new table and field with using (InventDimId & ItemId) and create relation with InventDim
  2. Add InventDim and new table datasource in standard form and join (Inner Join) it with datasource which contains your item id & inventDimid  (new Table)
  3. Create a new group under your gird. Set its datasource property to InventDim and Data group property to InventoryDimesions
  4. Add InventDimParmFixed Display menu item to your Tab->action pane menu.
  5. Add new and delete line command tab on Tab page
  6. Write code  on form Methods

Code:

  • Create new extension class for standard FORM

Code:                                                         Public  InventDimCtrl_Frm_EditDimensions           inventDimFormSetup;

    public Object inventDimSetupObject()

    {

        return inventDimFormSetup;

    }

    public void init()

    {

        FormRun             formRun                 = this as FormRun;

        next  init();

        formRun.updateDesign(InventDimFormDesignUpdate::Init);

    }

    public void updateDesign(InventDimFormDesignUpdate mode)

    {

        InventDimParm inventDimParmVisible;

        FormRun             formRun                 = this as FormRun;

        FormDataSource      formDataSourceParent    = formRun.dataSource(tableStr(<TableName>));

        <TableName>         <TableName>             = formDataSourceParent.cursor();

        switch (mode)

        {

            // Form Init

            case InventDimFormDesignUpdate::Init    :

                if (!inventDimFormSetup)

                    inventDimFormSetup  = InventDimCtrl_Frm_EditDimensions::newFromForm(formRun);

                   inventDimFormSetup.parmSkipOnHandLookUp( true);

                    inventdimparmvisible.InventColorIdFlag = true;

                   inventdimparmvisible.inventsiteidflag       = true;

                   inventdimparmvisible.InventLocationIdFlag       = true;

                   inventDimFormSetup.parmDimParmVisibleGrid(inventDimParmVisible);

                    break;

            // Datasource Active

            case InventDimFormDesignUpdate::Active  :

               inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(<TableName>.ItemId));

                inventDimFormSetup.formSetControls( true);

               inventoryDimensionsGrid.allowEdit(true);

            // Datasource Field change

            case InventDimFormDesignUpdate::FieldChange :

               inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(<TableName>.ItemId));

               InventDim.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled());

                inventDimFormSetup.formSetControls( true);

               inventoryDimensionsGrid.allowEdit(true);

                break;

            default :

                throw error(strFmt (“@SYS54195”, funcName()));

        }

    }

    /// <summary>

    /// Modifies inventory dimension field.

    /// </summary>

    public void modifyInventDimField(FieldId _fieldId)

    {

        FormRun             formRun                 = this as FormRun;

        FormDataSource      formDataSourceParent    = formRun.dataSource(tableStr(<TableName>));

        <TableName>         <TableName>             = formDataSourceParent.cursor();

        FormDataSource      formDataSourceChild     = formRun.dataSource(tableStr(InventDim));

        InventDim           inventDim               = formDataSourceChild.cursor();

        if (<TableName>.modifyInventDim(inventDim, _fieldId))

        {

            inventDim.data(<TableName>.inventDim());

        }

    }

  • Create new extension class for Standard Form, Chlid DataSource (InventDim) using FORM COC

Code:

void initValue()

    {

        FormDataSource      formDataSourceParent    = this;

        FormRun             formRun                 = formDataSourceParent.formRun() as FormRun;

        FormDataSource      formDataSource          = formRun.dataSource(tableStr(<TableName>));

        <TableName>         <TableName>             = formDataSource.cursor();

        InventDim           inventDim               = formDataSourceParent.cursor();

        InventDim.data(InventDim::find(<TableName>.InventDimId));

        formDataSourceParent.setCurrent();

        next initValue();

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, configId), FormDataFieldEventType::Modified)]

    public static void configId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, ConfigId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, inventBatchId), FormDataFieldEventType::Modified)]

    public static void inventBatchId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, inventBatchId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, InventColorId), FormDataFieldEventType::Modified)]

    public static void InventColorId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, InventColorId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, InventLocationId), FormDataFieldEventType::Modified)]

    public static void InventLocationId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, InventLocationId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, inventSerialId), FormDataFieldEventType::Modified)]

    public static void inventSerialId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, inventSerialId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, InventSiteId), FormDataFieldEventType::Modified)]

    public static void InventSiteId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, InventSiteId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, InventSizeId), FormDataFieldEventType::Modified)]

    public static void InventSizeId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, InventSizeId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, InventStatusId), FormDataFieldEventType::Modified)]

    public static void InventStatusId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, InventStatusId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, InventStyleId), FormDataFieldEventType::Modified)]

    public static void InventStyleId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, InventStyleId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, wMSLocationId), FormDataFieldEventType::Modified)]

    public static void wMSLocationId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, wMSLocationId));

    }

    [FormDataFieldEventHandler(formDataFieldStr(<FormName>, InventDim, wMSPalletId), FormDataFieldEventType::Modified)]

    public static void wMSPalletId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        formRun.modifyInventDimField(fieldNum(InventDim, wMSPalletId));

    }

  • Create new extension class for Standard FORM Parent Datasource and write below code methods using Form COC (new table)

Code:

    void initValue()

    {

        FormDataSource      formDataSource          = this;

        FormRun             formRun                 = formDataSource.formRun() as FormRun;

        FormDataSource      formDataSourceParent    = formRun.dataSource(tableStr(MCRHoldCodeTable));

        <TableName>         <TableName>             = formDataSource.cursor();

        <Parent Form Table>    <ParentTable>        = formDataSourceParent.cursor();

        next initValue();

        <TableName>.<Unique Field> = <ParentTable>.<Unique Field>;

    }

    int  active()

    {

        int                                 ret;

        ret = next  active();

        FormDataSource      formDataSource          = this;

        FormRun             formRun                 = formDataSource.formRun() as FormRun;

        formRun.UpdateDesign(InventDimFormDesignUpdate::Active);

        return ret;

    }

    public void init()

    {

        next init();

    }

    /// <summary>

    /// Updates <c>InventDim</c> with new data which has been set due to modification of <c>form name</c>.

    /// </summary>

    public void initInventDim()

    {

        FormDataSource      formDataSource          = this;

        FormRun             formRun                 = formDataSource.formRun() as FormRun;

        <TableName>         <TableName>             = formDataSource.cursor();

        FormDataSource      formDataSourceParent    = formRun.dataSource(tableStr(InventDim));

        InventDim           inventDim               = formDataSourceParent.cursor();

        InventDim.data(InventDim::find(<TableName>.InventDimId));

        formDataSourceParent.setCurrent();

    }

    void  write()

    {

        FormDataSource      formDataSource          = this;

        FormRun             formRun                 = formDataSource.formRun() as FormRun;

        <TableName>         <TableName>             = formDataSource.cursor();

        FormDataSource      formDataSourceParent    = formRun.dataSource(tableStr(InventDim));

        InventDim           inventDim               = formDataSourceParent.cursor();

        next write();

        <TableName>.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;

        if (<TableName>.InventDimId != inventDim.InventDimId)

        {

            inventDim.data(InventDim::find(<TableName>.InventDimId));

            formDataSourceParent.setCurrent();

        }

        formDataSource.reread();

        formDataSource.reread();

    }

            FormDataFieldEventHandler(formDataFieldStr(<FormName>, <TableName>, ItemId), FormDataFieldEventType::Modified)]

    public static void ItemId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        FormRun     formRun = sender.datasource().formRun() as FormRun;

        FormDataSource      formDataSourceChild     = formRun.dataSource(tableStr(InventDim));

        InventDim           inventDim               = formDataSourceChild.cursor();

        formRun.updateDesign(InventDimFormDesignUpdate::FieldChange);

        inventDim.clearNotSelectedDim(formRun.inventDimSetupObject().parmDimParmEnabled());

    }

 
Leave a comment

Posted by on February 13, 2019 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
365 by Thijs

Blogging about Microsoft 365, Azure and Automation!

axhowto

Blog about ax with sample codes, tips and tricks.

GM Dynamics Blogs

Transform IT with Digital Trasformation and Social Innovation

Ms. Dynamic Millennial

Unboxing Microsoft Dynamics 365 for Finance and Operations

DynaD365Power

Exploring the new vision of the Power platform

Dynamics Vision 365

The FinOps pulse

Breaking Bong

I write when no one is watching

ErpCoder

Microsoft Dynamics 365 Business Management Solution Enthusiast

Dynamics 365 Finance

Dynamics 365 Finance & Much More.

Microsoft Dynamics AX

“ANYONE WHO STOPS LEARNING IS OLD, WHETHER AT TWENTY OR EIGHTY.” —HENRY FORD

Sumit Potbhare

Dynamics 365 for Commerce

iotsolution.se

This is your site about D365 (Finance and Supply Chain Management), IoT (Internet of Things) and HoloLens

Omni 365

Dynamics 365 Finance and Operations Blog

DIY D365

Power Platform Done Your Way

%d bloggers like this: