Foreign Key Relationship in D365 F&O

Rumman Ansari   Software Engineer   2023-05-23   2398 Share
☰ Table of Contents

Table of Content:


Foreign Key Relationship in D365 F&O

Foreign key relation - Specifies a correspondence between a foreign key field in the present table (Child Table) and the primary key field in another parent table.

Foreign Key Relationship in D365 F&O

When we want 1 to Many (1:M) Relationship then we use Foreign Key relation.

Foreign Key Relationship in D365 F&O

Know How to create a Foreign Key Relationship

Create Parent table SalesHeader and fields. Also create Index and copy SalesId on that Index and set property Allow duplicate to No.

Foreign Key Relationship in D365 F&O

Now create a child table SalesTrans and add fields. Create one Foreign Key relationship then set bellow properties.

Foreign Key Relationship in D365 F&O

Set bellow properties. It is best practice that you are giving the name of the relationship to which it is related, in our case it is SalesHeader.

Foreign Key Relationship in D365 F&O

Create a new normal relationship SalesTrans Table

Foreign Key Relationship in D365 F&O

Now set below properties for the normal relationship.

Foreign Key Relationship in D365 F&O

SalesHeaderTable Output

Foreign Key Relationship in D365 F&O

If you will try to add S01 record which is already present SalesHeaderTable then you will get error. You will not be able to add this S01 record, because S01 already present. In this Header table Sales Id can't be duplicate because Allow duplicate property is set to NO. If you will try to add you will get error message.

Foreign Key Relationship in D365 F&O

You will get below error.

Foreign Key Relationship in D365 F&O

SalesTrans Table Output

Foreign Key Relationship in D365 F&O