Unleashing Dynamics 365 Excellence: Your Source for Pro Tips and Snippets at D365Snippets.com

Our blog provides a curated collection of tips, tricks, and code snippets that streamline your workflow and enhance your proficiency.
Unleashing Dynamics 365 Excellence: Your Source for Pro Tips and Snippets at D365Snippets.com

Table Relations in D365 with Examples

0

A table relation associates two tables that contain related information. Usually, the primary key field of one table appears as a foreign key field of the related table. The table with the primary key is called the parent table. The table with the foreign key is called the child table.

For example, a parent table named Department can have a departmentId field as its primary key. A child table named Employee can have a departmentId field as a foreign key. All values in the foreign key field must exist in the primary key field of the parent table. Any value in the foreign key field can be used to find the parent row that contains the matching primary key value. Then any other field in the parent row can be accessed.

In the previous articles, we have already read Delete Actions In D365. If you are a beginner or learner use Microsoft's free VM, there you can access both the Technical and Functional environments for developing your knowledge in D365 Finance and Operations.

Table Relations in D365 with Examples

Use of table relations

A relation on a table can restrict the rows in the table, or restrict the values that can be in particular fields. A common use of relations is to associate rows in one table with corresponding rows in another table. Relations enable many forms to display data from multiple tables.

Some relations restrict the rows in the table by testing the values in each row against constant values. Other relations restrict the rows by comparing values in each row to values in a row in another table.

Example of Table Relation

A PurchaseOrder Table contains all the supplier orders and might have a field called VendId, which keeps the value of the associated Vendor Id for the purchase order. The VendTable contains all the vendor records and has a filed name VendId.

Here VendId in the VendTable is called as primary key, and VendId in the  PurchaseOrder Table is called the foreign key. This is a simple example of table relations. 

To create a table relation specifies that PurchaseOrder.VendId=VendTable.VendId

Table Relations in D365

How to add a relation to a table in D365

  • In the AOT, move to Data Dictionary > Tables, and then expand the table that the relationship that will be added.
  • Right-click the Relations node, and then select New Relation.
  • Right-click the newly added relation, and then select Properties.
  • Set the name of the new relationship by modifying the Name property.
  • In the Table property, select the related table.
  • Use the Validate property to determine whether the relationship should be used to validate data when information is entered into forms.
  • 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.

In Microsoft Dynamics 365 there are 

  • Normal Relation
  • Field Fixed Relation
  • Related Field Fixed Relation
  • Foreign Key Relation

1. Normal

A normal relation is used to specify a relationship without any conditions. A normal relation specifies related fields in another table. Multiple fields can also be added in normal relations. you can read more about the Normal Relation in D365 from the article Normal Relation in the Article with Example

Condition is,  Table1.Field = Table2.Field

2. Field Fixed

Field Fixed Relation is used to specify relation fields to restrict the records in the primary table. Only records that meet the condition are selected. The field fixed is normally an enum.

The condition is ANDed with your relation here

Table.Field = <EnumValue>

Read More: Field Fixed Relation in D365 with Example

3. Related Field Fixed

Field Fixed Relation is used to specify relation fields to restrict the records in the related table. Only records that meet the condition are selected. The field fixed is normally an enum. The field fixed is normally an enum. 

The condition is ANDed with your relation here.

<EnumValue> = Table.Field

4. Foreign Key

Foreign Key Relation is used to specify a correspondence between a foreign key field in the present table to the primary key field in another parent table.

Post a Comment

0Comments
Post a Comment (0)