• No results found

Extended Data Types

In document DAX Hand Book (Page 123-127)

Let us consider a scenario, where we have a field like CustomerId in your requirement. You have created this field in nearly 100+ tables and used the same field for reference in 100+ code snippets and declaration sections as the business mostly depend on Customers. The size of the CustomerId was planned to be 5 in number of characters, but very soon, it grew to 6 and its time to update the field size.

I like to know the plan of action followed by you to get the work done quickly.

 Open each table and update the properties of the field CustomerId.

 Update at one place which will update at all places.

I’m sure, I’ll prefer second one than first one if possible as first will consume large volume of time which will increase cost and decrease productivity and may be error prone as even if the update is missed at a single place, will lead to data problems which may not be recovered most of the times.

But, how and using what kind of object this is possible? Answer is, Extended Data Type, shortly, EDT. EDT’s are the types created from basic or another EDT. EDTs extend primitive types or other EDTs

i.e. they inherit properties from other EDTs or primitive types which can be changed according to business requirements. Following are benefits of creating EDTs:

 Reuse of the properties.

 Efficient maintenance i.e. the properties of many fields can change at one time by changing the properties on the EDT.

 A table field that is created based on an EDT will also inherit properties from that EDT, which will make many fields change at one time possible.

EDTs are central part of AX. Whether we create tables or declare fields, we mostly depend on EDTs as when we update EDTs, it will reflect where ever we use that EDT. We will try to understand how to create EDTs in the following lab. The requirement for creating an EDT is, for truck table. Trucks are used to deliver goods from company store/warehouse to customer/reseller store. We need TruckId, Description and Date fields for trucks master which will need EDTs. Please note that standard AX 2012 will give us around 9000+ EDTs and it seems like we don’t need any extra EDTs to define. Let’s find if there are any existing EDTs that support for our requirement:

Description >Description255 will work for the current scenario.

Date > TransDate will work for the scenario to store date.

With enough information, it’s time to create an EDT for TruckId which is not available, and as per the requirement we don’t have any EDT that suite. So, we will create a new EDT with the following properties. To create an EDT, follow

these steps:

 Expand the DataDictionary node in AOT;we will see a node called Extended Data Types.

 TruckId is an alphanumeric and so, we will take string to store the values. Right click on Extended Data Types > Click New > String. You will see a lot of other primitive types and can be used to create EDTs as per business requirement.

 Now, let’s update few

properties. Right click on newly created EDT and click on properties.

You will find few properties in adjacent image.

 The name property, we will rename from Type1 to TruckId. Note

that, we will find few colors in properties of few properties. The reddish color indicates that property value should be mandatory and yellowish is optional but recommended.

 We will add the values to Label and Help Text as “Truck id”

and “Used to store value of truck identification number.” Note that, the labels and help text should be added label ids instead of plain text but for time being we will add text and will update once we go through label wizard which will be covered in coming text.

 We are able to see one more property called Extends, which is used if we like to inherit the properties of another EDT. This is a kind of inheritance where the properties of one EDT are inherited into another. Currently, let’s leave the field as it is. We will get to this property if required in coming text.

Note that, we can inherit EDTs to any number of levels as per requirement and availability as in

below EDT for example:

 Now, let’s update the string size to 20, alignment to Left and Change Case to UPPER CASE which will satisfy the business requirement. Once everything is

done, the properties should look as in the adjacent image.

The same way, create one more EDT for the Zone table. The EDT has following criteria:

ZoneId: This EDT is a string which will divide locations into various zones and is a string value.

Once EDT is created and saved, AX may synchronize tables which may take few minutes depending on the machine performance and it is recommended to continue and not to disturb or close the synchronizing.

Note: We can update the properties of the EDT at any point of using the application. This will update the properties of the EDT where ever it is used for instance, the table in database i.e. SQL Server or Oracle, wherever it is installed. To do this updation, this will synchronize (which will take few minutes) and is recommended to continue synchronizing though it is a bit time consuming.

If you further expand the newly created EDT node, you‘ll see 2 nodes, Array Elements and Table References. Array Elements are a powerful feature of EDTs which provide a great advantage. When we use this EDT to create field in tables or any code snippet, this will create a multi valued variable in code and multiple fields which is equal to the array size in physical table in database. Let us consider a scenario, where we need to store the dimensions of truck i.e. length, breadth, volume and capacity of truck. We will create an EDT as follows:

 Create an EDT of type integer and name it TruckDimensions.

 Expand the EDT newly created and right click on TruckDimensions, click on New Array Element. Name it TruckBreadth, give a proper label. You can identify the Index being 2.

 Add 2 more array elements namely, TruckVolume and TruckCapacity, you will see that the indexes are given values 3 and 4 for the newly created array elements.

 Finally, check the array length of TruckDimensions, which will be 4.

Now, when you use this EDT, each array element of an extended data type will be created as a database field. Both from the AOT and from X++ a field based on an extended data type array will look like, and be addressed as, any other field. Note that the first entry of the array will be entry created when creating an EDT. All the other entries are created under Array elements node. All the properties of these Array Elements are inherited from the first entry created i.e. EDT created. We have Label and Help Text properties which can be set on EDT Array Elements and we can find a node named Table References if we further expand each Array Element that can be used to configure each Array Element.

EDTs in AX 2009:

EDTs in Microsoft Dynamics AX 2009 are similar to 2012 but, have a node called relations, which are used to create EDT relations. EDT relations are similar to Table relations, which are used to establish relations that work throughout AOT where ever the EDT is used. EDT relations are 2 in number, Normal and Related Field Fixed. As these are obsolete in AX 2012 and only table relations are used, we skip this topic at this point as we will see the table relations and will discuss the relations in coming text in table relations. This relations node is replaced by Table References in AX 2012.

In document DAX Hand Book (Page 123-127)

Related documents