Thursday, December 27, 2018

Cardinality and RelatedTableCardinality table relation property in AX 2012


Specifically, the Cardinality property corresponds to the notation on the child table (SalesLine in this case). So it should be ZeroMore (0…*).

RelatedTableCardinality property corresponds to the notation on the parent table (SalesTable). So it should be ExactlyOne (1:1).

Semantically, Cardinality specifies how many instances of SalesLine row can be related to a single instance of SalesTable row. ZeroMore means that for every sale order, there can be zero, or more sales lines related to it. If the business requirement dictates that you need to have at least one sales line to be able to create a sales order, the Cardinality would be OneMore (1:*).

RelatedTableCardinality specifies how many instances of SalesTable row can be related to a single instance of SalesLine row. ExactlyOne means that every sales line should belong to one and only one sales order.

Friday, December 14, 2018

EDT and EDT Relation in AX 2012

Extended data types (EDTs) are user-defined types, based on the primitive data types

  • boolean, 
  • integer, 
  • real, 
  • string, 
  • and date, 
  • and the composite type container.

 You can also base EDTs on other EDTs.

An EDT is a primitive data type or container with a supplementary name and some additional properties.

For example, you could create a new EDT called Name and base it on a string.

Thereafter you can use the new EDT in variable and field declarations in the development environment.


The benefits of EDTs are as follows:


  • Code is easier to read because variables have a meaningful data type. For example, Name instead of string.
  • The properties you set for an EDT are used by all instances of that type, which reduces work and promotes consistency. For example, account numbers (AccountNum data type) have the same properties throughout the system.
  • You can create hierarchies of EDTs, inheriting the properties that are appropriate from the parent and changing the other properties. For example, the ItemCode data type is used as the basis for the MarkupItemCode and PriceDiscItemCode data types.


Define an Extended Data Type as an Array :

You can create an extended data type in the Application Object Tree (AOT) that contains multiple elements. This enables you to store multiple data elements in a single field that is based on this extended data type.

A typical example is an extended data type for handling an address. Instead of defining three fields on your form to enter the address, you can define an extended data type with three elements (the first element exists by default), as shown in the following figure.

Extended Data Types in the AOT


When you create a form based on a table that contains a field of the MyAddress type, MorphX automatically generates a field on your form for each element in the MyAddress definition. The definition of the MyAddress type above causes 3 fields to be generated on a form, called Address, Address1, and Address2.


EDT Relations :


  • We can create the relation in AX with the help of EDT.
  • After creation of EDT in the AX we have to assign the "Reference Table" in the property then we can assign the reference table field in the Table reference node.
  • drag it under fields nodes of your table and it will prompt you for foreign key relationship. if you hit YES, it is going to work and create relationship automatically. 


Monday, December 10, 2018

To fetch Department Dimension using X++

public void lookup()
{
    Query                   query  = new Query();
    QueryBuildDataSource    qbds;
    SysTableLookup          sysTableLookup;
    sysTableLookup = sysTableLookup::newParameters(tableNum(OMOperatingUnit),this);
    sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,OMOperatingUnitNumber));
    sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,Name));
    sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,OMOperatingUnitType));
    sysTableLookup.addSelectionField(fieldNum(OMOperatingUnit,Name));
    qbds = query.addDataSource(tableNum(OMOperatingUnit));
    qbds.addSortField(fieldNum(OMOperatingUnit,OMOperatingUnitNumber));
    qbds.addRange(fieldNum(OMOperatingUnit,OMOperatingUnitType)).value(enum2str(OMOperatingUnitType::OMDepartment));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...