Axaptapedia is now maintained by AgileCadence For more information please click here.

Extended Data Types

From Axaptapedia
Jump to: navigation, search

Introduction[edit]

Extended data types are very important and if used correctly, very powerful. An extended data type is a user-defined definition of a primitive data type. The following primitive data types can be extended: boolean, integer, real, string, date and container.

Inheritance[edit]

Name is a standard string EDT that represents the name of a person, company or object. If a property on Name is changed, all EDT's that inherit from it will automatically reflect the changed value. For example if the standard length is not long enough, it can be increased and all child EDT's will automatically be increased along with it. All database fields, forms and reports where the EDT is used, will also reflect the changed property.

Properties[edit]

Some of the properties that can be modified are StringSize, Alignment, DisplayLength, Label and HelpText.

Number sequences[edit]

When creating a number sequence, an extended data type is required to associate the number sequence with. See Number_sequences.

Advantages[edit]

  • Consistency in data model, forms and reports.
  • Automatic lookups (if table relation property is set).
  • Improve readability in code.

Creating programmatically[edit]

Ax 3.0[edit]

There doesn't seem to be any methods in the treenode class to allow this. (I guess that is why they added the AOTTableFieldList class).

My only suggestion would be to export a "template" dict type and use the infolog.importElement() method to bring it in as a new one. To see how this is used look at the class sysImportElements.

You can also use the following code snippet: <xpp>

static void Job19(Args _args)
{
   UtilIdElements uie;
   XInfo XInfo = new XInfo();
   TreeNode TNode;
   TreeNode DNode;

   str      Props =
       "PROPERTIES\n" +
       "  Name                #AXUStr35\n" +
       "  Label               #\n" +
       "  HelpText            #\n" +
       "  FormHelp            #\n" +
       "  ArrayLength         #1\n" +
       "  DisplayLength       #Auto\n" +
       "  ConfigurationKey    #\n" +
       "  ButtonImage         #Arrow\n" +
       "  Extends             #\n" +
       "  DisplayHeight       #Auto\n" +
       "  StringSize          #35\n" +
       "  Adjustment          #Left\n" +
       "  Alignment           #Auto\n" +
       "  ChangeCase          #Auto\n" +
       "ENDPROPERTIES\n";

   select maxof(id) from uie where uie.recordType == UtilElementType::ExtendedType && uie.utilLevel  == XInfo.currentAOLayer();

   uie.id++;
   uie.utilLevel  = XInfo.currentAOLayer( );
   uie.recordType = UtilElementType::ExtendedType;
   uie.name       = "AXUStr35";

   uie.insert();
   DNode = TreeNode::findNode("Data Dictionary\\Extended Data Types");
   DNode.AOTrefresh();

   TNode = TreeNode::findNode("Data Dictionary\\Extended Data Types\\AXUStr35");
   TNode.sysUtilDelete();

   TNode.AOTsetProperties(Props);
   TNode.AOTsave();

   pause;


}

</xpp>

Ax 4.0[edit]

(thanx to Ed Tarnovsky) <xpp>

  treeNode = xInfo.rootNode();
  treeNode = treeNode.AOTfindChild('Data Dictionary');
  treeNode = treeNode.AOTfindChild('Extended Data Types');
  treeNode=treeNode.AOTaddExtendedDataType(_EDT,Types::String);
  treeNode.AOTsetProperties(Props);

</xpp> Also they open up relation node of the EDT to add through aotAdd()

See also[edit]

Types