Monday, March 17, 2014

Table Inheritance in Ax 2012

In Microsoft Dynamics AX 2012, tables can inherit, or extend, from the tables that are situated above them in a hierarchy. 
A base table contains fields that are common to all tables that derive from it
- The table properties "Extends", "SupportInheritance" are used in the table inheritance hierarchy
- Table inheritance hierarchy can only be defined on a normal table type but not on tempdb, InMemory
- A type discriminator field must be defined on any table inheritance hierarchy created in the AOT. 
the field must be defined as an int64 type on the root table, with the name of the field set to InstanceRelationType. 
Furthermore, the developer must select this field as the value for the InstanceRelationType table property on the root table.
- In all the tables of inheritance hierarchy, the SupportInheritance property is set to Yes.Extends is set to the required tables
Do not create any fields in the table before completing the table hierarchy
Note: Field names must be unique across the entire table inheritance hierarchy. 
This requirement ensures that the field name uniquely identifies the field across the hierarchy 
when appearing in system APIs that reference table fields. 
Developers will also notice that field IDs are unique across the entire table inheritance hierarchy
- If you are displaying the instance type of the record on a form, and a report is needed then a enumerationt ype can be defined on the  base table with the values as the types of tables in the hierarchy
Override the insert table method on the base table and write the code as follows
For eg: Partytype enum on party table

DictEnum enumType = new DictEnum(enumnum(partytype));
int enumValue;
if (this.DisplayRelationType != partytype::Unknown)
{
return;
}
enumValue = enumType..symbol2Value(this.getInstanceRelationType());
if (enumValue == 255) // symbol2Value returns 255 if cannot convert
{
throw error(strfmt('No %1 enum element found for EnumValue %2',
enumstr(partytype),
this.getInstanceRelationType()));
}
else
{
this.DisplayRelationType = enumValue;
}
super();
- 
Developers can now use a new developer tool, the Type hierarchy browser to visualize the table inheritance hierarchy in a more intuitive way. 
Developers can access the tool by right clicking the AOT Tables node, 
and then clicking Add Ins > Type hierarchy browser

Saturday, February 22, 2014

Create ssrs reports in ax 2012

Reports in Microsoft Dynamics Ax 2012 are based on SQL Server reporting services (SSRS)
SSRS

Before designing and executing the Report, SSRS needs to be configured.

We can use a Query as a datasource or use report data provider class.

1. Using a query as datasource :

    --  Create a new query in AOT TestQuery with required datasource

    --  Open visual studio and create a new Dynamics AX project
 
   

   -- Select Microsoft Dynamics AX from the installed templates -> report model and name the model

   

  -- Add a new report to the newly created report Model as shown below

  

  -- Then add the dataset to the newly created report.
      Right click on the datasets node and chose the option New datset
      Set the Query property to the newly created query.
      Then you can select the desired list of fields.
 --  Under the design section you can create 2 types of design, auto design and precision design
 --  Auto design arranges the fields and layout automatically whereas in precision we can customize the       design
--  Select the dataset and drag and drop on to your designs node it creates an auto design
     Under the design node we can select multiple properties to control the report preview

--  After completing the above steps rt. click on report model and select add to AOT property to deploy      the report

--  When we come back to Ax the report can be seen in below path
      AOT ->  Visual studio projects -> Dynamics AX Model projects
      AOT ->  SSRS Reports -> Reports

--  After this we can create a output menu item and select the newly created report in the properties.
     to execute the report.

2. Using Report data provider.
 

   --> For this first we need a temp table to store the report data and create required fields.
   --> It is best to decide on the fields of table before starting the design of the report in  
          visualstudio designer
   --> Once the table is completed we need to create controller, contract and data provider classes
   --> After this a new Dynamics Ax model project can be created in visual studio and a new               
         report can be added as in the above section.
   --> When adding the dataset to the report set the newly created data provider class
   --> Under the design node you can select a new precison design and start designing the report
         based   on your requirement
   --> After completing the above steps rt. click on report model and select add to AOT property to
         deploy the report


   





Sunday, December 22, 2013

Setting an entity to be dimensionable


To set an entity to be dimensionable, create a view as directed below. The entity will automatically appear as an available backing entity type.
Also, to integrate with the dimensions framework when deleting or renaming the natural key of the backing entity, you must write custom code on the backing table's delete method, and also on either the update or renamePrimaryKey method. See CustTable for an example of the pattern these methods must follow.
1. The view name must be DimAttribute[yourentityname]. For example, DimAttributeCustTable.
2. The view must contain a root data source named BackingEntity that points to your backing table to identify a surrogate key and natural key.
3. The view may optionally contain additional related data sources to handle inheritance or relational associations to provide additional fields, such as a name from the DirPartyTable.
4. The view must contain the following fields named exactly as follows:
Key - Must point to the backing entity's SK field. For example, an int64 RecId field.
Value - Must point to the backing entity's NK field. For example, a str30 AccountNum field.
Name - Must point to the source of an additional description for the entity. For example, a str60 Description field.
5. The view must have a SingularLabel assigned that is different from its Label property.
6. The view must have the same ConfigKey as the backing table.
7. The view must be included in the DimensionEssentials Security Privilege.
Because the list of dimensionable entities are cached on both the client and server, the creation of a new dimensionable entity will not appear in the list of existing entities until a call to clear the caches is performed, or until both the client and the server are restarted. In order to clear the caches and have the new backing entity appear immediately, you must execute the following line of code within a job:
DimensionCache::clearAllScopes();

If a new Organization Model OMOperatingUnitType enumeration is added, the steps to make it dimensionable are similar but can be made shorter as follows:
1. Copy one of the existing DimAttributeOM[entityname] views, rename it appropriately and adjust all associated labels and help text.
2. Expand the Datasource\BackingEntity (OMOperatingUnit)\Ranges node on the copied view and change the value property on the range to the new OMOperatingUnitType enumeration value that was just added.
Because the OMOperatingUnitType is backed by the OMOperatingUnit table, generic code already exists to handle the delete, update and renamePrimaryKey methods. Therefore, in this case, you do not need to update these methods.

Dimensions framework in AX 2012

In Microsoft Dynamics AX 2012, the account and financial dimensions framework has been enhanced to provide
more functionality.
To support this new functionality, the data model has also been completely redesigned.
Therefore, developers will need to update every reference to ledger accounts and financial dimensions
in existing applications to reference the new data model.

Segmented Entry control:
Account form controls combine the Segmented Entry control and a controller class. 
The Segmented Entry control is a general-purpose Microsoft Dynamics AX client control that is being introduced in AX 2012. 
The controller class is an X++ class that handles the events raised by the Segmented Entry control. 
The combination of a control and an underlying class allows the user to see a dynamic number of segments, based on the values the user provides

Main account and ledger account :
In previous versions of Microsoft Dynamics AX, the term ledger account was used to specify what is now referred to as the main account
In AX 2012, the main account is merged with financial dimensions to create a more integrated view of the chart of accounts
In AX 2012 a ledger account contains the main account, account structure, and the financial dimension values that are needed to populate the related account structure ledger account is a 64-bit integer field that contains the data from the corresponding RecId field in the DimensionAttributeValueCombination table

In previous versions of Microsoft Dynamics AX, the term ledger account was used to specify what is now referred to as the main account
In AX 2012, the main account is merged with financial dimensions to create a more integrated view of the chart of accounts
In AX 2012 a ledger account contains the main account, account structure, and the financial dimension values that are needed to 
populate the related account structure ledger account is a 64-bit integer field that 
contains the data from the corresponding RecId field in the DimensionAttributeValueCombination table

Changes needed on the form to add segmented entry control:

Add the LedgerDimension field from the data source to the desired location on the form design. 
This should add a Segmented Entry control at this location on the form with appropriate DataSource and ReferenceField property values.
Or add a Segmented Entry control to the design and manually setting the DataSource and ReferenceField properties

Add the following code in the init method

ledgerDimensionDefaultAccountController =
LedgerDimensionDefaultAccountController::construct(myTable_ds, fieldstr(MyTable, LedgerDimension));

Following methods on the form needs to be overriden for the segemnted control

jumpRef, validate,loadSegment, segmentValueChanged, loadAutoCompleteData, resolveReference(dataSource)

Classes related to dimensions:
Some of the classes can  be used to implement/ make use of dimension framework
DimensionDefaultingController class handles drawing of individual field controls for each financial dimension for the 
current ledger’s account structures, and field entry/validation, lookup, and “view details” functionality
Classes like DimensionDefaultingEngine, DimensionDefaultingService, DimensionStorage etc can be used to perform various operations on dimesnions like get dimension data, build dimesnions etc..

e.g: DimensionStorage::getDefaultDimensionFromLedgerDimension: Gets the default dimension that represents all dimension values from the specified ledger account other than the main account.
DimensionDefaultingEngine::overrideDefaultDimension: Updates a default dimension with the specified dimension values.


Tuesday, September 4, 2012

Ax2012 SSRS Report Error

When designing SSRS reports in Ax2012, sometimes when we do changes to report's temporary tables (like adding/removing fields) the change is not reflected in the report even if we deploy the report or restart the AOS.
I have added a new field in the report temporary table and refreshed the dataset in the visual studio.But the field is not updated in the ssrs report. I tried restarting AOS and deploying the report but none of them worked.Finally i tried restarting the SQL reporting services and it worked.

Restarting the SQL Sever Reporting Services will solve the problem and update the table properly.

Friday, July 22, 2011

Code named ‘Windows 8’

Building windows 8 - video#1

http://blogs.msdn.com/b/deva/archive/2011/07/22/code-named-windows-8.aspx