Thursday, 24 April 2014

Relation in Ax 2012 (relation data base)

The initial steps for adding a relation are the same regardless of the relation type that you are adding. The later steps diverge based on the relation type.
Remember to save your changes in the AOT.
  1. In the AOT, move to Data Dictionary > Tables, and then expand the table that the relation will be added to.
  2. Right-click the Relations node, and then select New Relation.
  3. Right-click the newly added relation, and then select Properties.
  4. Set the name of the new relationship by modifying the Name property.
  5. In the Table property, select the related table.
  6. Use the Validate property to determine whether the relation should be used to validate data when information is entered into forms.
  7. Right-click the new relation, select New, and then click one of the following:
  • Normal to specify relation fields without conditions.
  • Field fixed to specify relation fields to restrict the records in the primary table.
  • Related field fixed to specify relation fields that restrict the records in the related table.
  • ForeignKey to specify a correspondence between a foreign key field in the present table to the primary key field in another parent table.


Related Fixed Field Relation in AX 2012

1. Create four tables
S.No
Name
1.
ClothesTable
2.
MenClothesOrder
3.
WomenClothesOrder
4.
ChildrenClothesOrder

2. Create BaseEnum "CollectionTypeId" with the following elements:
S.No
Name
EnumValue
1.
Men
0
2.
Women
1
3.
Children
2

3. Create ExtendedDataType "CollectionTypeEDT" and set EnumType property as BaseEnum "CollectionTypeId".

4. Add following fields and set properties for " ClothesTable".
S.No
Name
Data Type
ExtendedDataType
1.
ClotheId
String


2.
Name
String


3.
CollectionTypeId
--
CollectionTypeEDT

5. Add following fields in "ChildernClothesOrder", "MenClothesOrder" and "WomenClothesOrder" :-
1. ClotheId 2. OrderId
3. Qty

6. On
"MenClothesOrder" create a new relation with "ClothesTable" and specify the follwing two relations:

1.
Normal Relation between MenClothesOrder.ClotheId and ClothesTable.ClotheId
2.
Related Fixed Field Relation and set following properties.
Field=CollecTionTypeId
Value= 0
SourceEDT = CollectionTypeEDT


7. On
"WomenClothesOrder" create a new relation to "ClothesTable" and specify the follwing two relations:

1.
Normal Relation between WomenClothesOrder.ClotheId and ClothesTable.ClotheId

2.
Fixed Field Relation and set following porperties:-
Field=CollecTionTypeId
Value= 1
SourceEDT = CollectionTypeEDT


Case 3:

7. On
"ChildernClothesOrder" create a new relation to "ClothesTable" and specify the follwing two relations:

1.
Normal Relation between ChildernClothesOrder.ClotheId and ClothesTable.ClotheId

2.
Fixed Field Relation and set following porperties:-
Field=CollecTionTypeId
Value= 1
SourceEDT = CollectionTypeEDT

********************************************
Relations
         Normal to specify relation fields without conditions.

         Field fixed to specify relation fields to restrict the records in the primary table.

         Related field fixed to specify relation fields that restrict the records in the related table.

         New ForeignKey to specify a correspondence between a foreign key field in the present table to the primary key field in another parent table.

Ex:-SalesTable->salesLine.

Normal Relation

1.       In the Field property, select the field in the primary table that relates to a field in the present table.

2.       In the RelatedField property, select the field in the related table.

Ex:-Salesline.salesid==SalesTable.salesid

Field fixed Relation

1.       In the Field property, select the field in the primary table to use to restrict the records.
n the Value property, enter the value of the selected field as the filter. This relates only records in the primary table that match that field value. Only numeric values can be entered in the Value property. Field fixed relations can be created only on numeric fields. Each of the related fields are AND ed in the table relation.

Ex:-Salesline.Salesid==1234

Related field fixed Relation

1.       In the Value property, enter the filter value of the selected field. This causes only records in the related table that match that field value to be related. Only numeric values can be entered in the Value property. Related field fixed relations can be created only on numeric fields.

2.       In the Field property, select the field in the related table to restrict the records. Each of the related fields are ANDed in the table relation.

Ex:- 1234==SalesTable.SalesId.

New ForeignKey Relation-2012

We often use the term child to refer to a table that has a foreign key column. And we use the term parent to refer to the other table that supplies the value for the foreign key column. But we never use the terms parent and child to describe the base and derived tables in an inheritance relationship.
1.       Set the Table property to the name of the parent table, the table that contains the primary key field.

2.       Set the RelatedTableRole property to a word or phrase that describes the purpose of the parent in the relationship.

Note
This value is added automatically as a method name on the child table. This method is displayed by IntelliSense in the X++ editor, but you cannot see the method in the AOT. For more information about how to use this method, see How to: Use the UnitOfWork Class to Manage Database Transactions.

3.       Set the Name property. A helpful value is a combination of the Table property and RelatedTableRole property values.

4.       Right-click the node for your relation, click New, and then click New ForeignKey. Next click either PrimaryKey based or Single field AlternateKey based. A new field is instantly added to the child table. This field stores the foreign key values.

5.       Under the Fields node, click the new field, and then change its Name property value.

6.       For performance benefits, you might decide to add an index on the new foreign key field. 




 


No comments:

Post a Comment

Labels

#veryusefulcode (1) AIF (8) AOT Maps (1) Args (1) Ax 2009 Reports (2) AX 2012 navigation (1) Ax 2012 Interview Questions (1) AX 7 (2) AX Architecture (1) Ax Backup (1) AX Workflow (2) AX2012 (1) AX2012 R2 (1) Ax2012R3 (1) AX2012R3 Dynamics Connector Step by Step Installation and Configuration (1) AX2012R3 EP Step by Step Installation and Configuration EP R3 (1) AX2012R3 HelpServer Step by Step Installation and Configuration (1) AX2012R3 Rapid Start Connector Step by Step Installation and Configuration (1) AX2012R3 Report Server and Analysis Server Step by Step Installation and Configuration (1) AX7 (1) Best practices (1) Blocking user to enter (1) Collection Classes (1) Container (1) D365FO (3) Data Migration Frame Work ax 2012R3 (1) Deleting duplicate Record from Table – Ax2012 (1) Delivery due date notification workflow in Ax 2012 (1) Development Steps EP (1) Dimensions (1) DIXF (1) DMF in Ax 2012 R3 (1) Dynamics Ax 2012 Interview Questions (1) DYNAMICS AX 2012 INTERVIEW QUESTIONS PART 2 (1) DYNAMICS AX 7 (1) EDT relation Migration Tool (1) EP AX 2012 (1) Ep Lookup (1) Error (1) Event Handler (1) F5 (1) File Handling (4) Filter on AX2012 Listpage (1) filtering (2) financial dimensions in AX 2012 (3) form (1) images (1) Installation and Configration (4) Installation and Configuration (11) Installation of Management Reporter 2012 for AX 2012 (1) Interaction class in ax 2012 (1) Interview Question (1) Interview Questions For Ax 2012 (1) Invent DIm (1) Jobs (2) license (1) List page and form menuitem enable code (1) Methods (1) microsoft Dynamics AX 365FO (1) Number Sequence Generation – AX 2012 (5) Number Sequence2012 (1) OLTP-OLAP (1) Passing Args (1) Passing form caller and menu item caller in ax 2012 (1) Passing Multiple Records Args (1) Posting in Ax 2012 (1) POSTING PURCHASE ORDER (1) Query (1) Query Filter Form (2) Query Ranges in X++ (1) Question and Answer (1) Report (1) Reports Controller class (1) RLS in ax 2009 (1) SALES ORDER IMPORT/EXPORT FRAMEWORK BY DMF (1) Security (1) security roles (1) Security Sysqueryrangeutil (1) Sharepoint 2016 (1) SQL SERVER (1) SSRS (2) SSRS Reports Controller class (2) Table collections & Virtual company (1) Time (1) TIPS AND TRICKS (1) Web service AIF (3) Web Services on IIS (AIF) Step by Step Installation and Configuration (1) workflow ax2012 (1) Workflow installation (1) Workflow Method (3) X++ (1)