Foreign Key Relationship in D365 F&O
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.
When we want 1 to Many (1:M) Relationship then we use Foreign Key relation.
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.
Now create a child table SalesTrans and add fields. Create one Foreign Key relationship then set bellow properties.
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.
Create a new normal relationship SalesTrans Table
Now set below properties for the normal relationship.
SalesHeaderTable Output
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.
You will get below error.
SalesTrans Table Output