Saturday, March 18, 2017

D365O - How to add financial dimension in grid

This post outlines the steps; how to add financial dimensions (segmented control) in a grid in D365O.

Let's assume we are adding new table and form for below explanation;

New table contains two fields AccountType and LedgerDimension with relation to DimensionAttributeValueCombination table 


Form looks like this;













Set properties for segmented control under form design;

- Auto declaration = Yes
- Account type field = AccountType
- Controller class = DimensionDynamicAccountController
- Filter expression = %1

















1. Override modified method for LedgerDimension field under form's datasource
2. Override lookup and checkUserCustomLookup method on ledger dimension segmented control in form desgin















Datasource | D365O_FinancialDimension | LedgerDimension | modified

[DataSource]
    class D365O_FinancialDimension
    {
        [DataField]
        class LedgerDimension
        {
            void modified()
            {
                super();

                D365O_FinancialDimension_ds.refresh();
            }

        }

    }

Desgin | D365O_FinancialDimension_LedgerDimension | lookup

        public void lookup()
        {
            switch (D365O_FinancialDimension.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, D365O_FinancialDimension);
                    break;
                case LedgerJournalACType::Vend:
                    VendTable::lookupVendor(this);
                    break;
                default:
                    super();
                    break;
            }
        }

Desgin | D365O_FinancialDimension_LedgerDimension | checkUserCustomLookup

public boolean checkUseCustomLookup(int _accountTypeEnumValue, int _secondaryAccountTypeEnumValue)
        {
            boolean returnValue;
           
            LedgerJournalACType accountType = any2Enum(_accountTypeEnumValue);
            switch (accountType)
            {
                case LedgerJournalACType::Bank:
                case LedgerJournalACType::Cust:
                case LedgerJournalACType::FixedAssets:
                case LedgerJournalACType::Project:
                case LedgerJournalACType::Vend:
                    returnValue = true;
                    break;
                default:
                    returnValue = false;
                    break;
            }
           
            return returnValue;
        }


Set D365O_FinancialDimensions form as startup object and run the form.























If you just want to see MainAccount in segmented control.

set the segmented control property Is default account = True






D365O - Import CSV data through Data entity

Data entity is a new concept comes with D365O release where each entity related data can be accessed from a single view.

A data entity is an abstraction from the physical implementation of database tables. For example, customer related data is stored in different tables in AX which could be customer address (access from  LogisticsPostalAddress), customer name (access from DirPartyTable), and customer electronic address (access from LogisticsElectronicAddress).

Complete details are well explained here 
https://ax.help.dynamics.com/en/wiki/data-entities/

Let's create new data entity to import data from a CSV file, this data entity uses only one table to keep it simple. My following posts will show how to import data into through data entities using multiple tables.

Create a new table [Optional step]

I created a new table for this example.
















Create new data entity

Method 1:

























Method 2:

Add new item for Data entity






















Provide table as primary datasource



















Click Next and mark convert labels to field names


















Data entity will look like this in Visual Studio














With both above methods (whatever you choose) it created few artifacts in your project.

- data entity
- security privileges
- staging table
















Build your project

Press Ctrl + Shift + B or Right click on project and Build

Synchronize your tables by Right click on project and Sync 

Validate staging table properties

Set the configuration key to DMF and all other properties should be same as set below.
















Import data using this data entity

System administration | Data management





















Provide a name, choose data source as CSV, and select entity name from the list. Upload file to import.

My sample file has this data

101, Faisal
102, Fareed
103, Mohammad














It prompts with fields mapping error














Click on View map and connect fields as shown














Refresh page to view this screen and click Run project.






















Follow next few prompts and execute the batch job to import data into the staging table, verify data in the staging table. Import data into the target which will change the transfer status to completed.







































Open DataImport data from table browser to see data.

This data entity creates view in SQL server, you can even play around with the created view in SQL server.


Refernceshttps://ax.help.dynamics.com/en/wiki/building-and-consuming-data-entities/

How to enable new Microsoft teams - Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Micr...