Field Fixed and Related Field Fixed relations in D365FO
Field Fixed
- So first let's create an enum for the party type (We could also have used the standard CustVendACType enum instead of creating a new one)
- Create the table with the two fields: PartyType and PartyReference
- PartyType: is the enum we just created, which indicates whether the party is a customer or vendor
- PartyReference: is the field that will store the accountNum for either the customer or the vendor (EDT used is CustVendAC)
- Now let's create a new relation between the "LJPartyReference" table and CustTable
- Go to the "Relations" node and create a new relation (name it "CustTable")
- Set "RelatedTable" to CustTable
- Then right-click on the "CustTable" relation and create a "Field Fixed" relation
- Set Field to "PartyType"
- Set Value to "LJPartyType::Customer"
- Right-click on the "CustTable" relation again and create a "Normal" relation
- Set Field to "PartyReference"
- Set RelatedField to "AccountNum"
- Repeat the same steps for the VendTable relation (create both Normal and Field Fixed relations) same as you did for CustTable in step 3
**This means that the relation between LJPartyReference and VendTable will be applied only when PartyType is Vendor. In other words, the PartyReference lookup will return records from VendTable only when PartyType is Vendor. - See how, when choosing Party Type as Customer, only customer accounts are returned in the Party Reference lookup
- Similarly, when choosing Party Type as Vendor, only vendor accounts are returned in the Party Reference lookup
**This means that the relation between LJPartyReference and CustTable will be applied only when PartyType is Customer. In other words, the PartyReference lookup will return records from CustTable only when PartyType is Customer.
Related Field Fixed
To solve this, we can create a Related Field Fixed relation.
- So first, let's create the Colour table with the three fields: ColourId, Name and Active
- ColourId: Identifies the colour (string, you can create its own EDT)
- Name: stores the colour name (string)
- Active: indicates whether the colour is active or not (Enum: NoYes)
- You can make the ColourId as unique index
- Let's also create the Product table with the two fields: ProductId and ColourId (The unique index is ProductId. For simplicity, we'll assume that one product can only have one colour)
- ProductId: Identifies the product (string)
- ColourId: stores the colour assigned to the product (string)
- Now let's create a new relation between the Product table and Colour table:
- Go to the "Relations" node in LJProduct table and create a new relation (name it "LJColour")
- Set "RelatedTable" to LJColour
- Then, right-click on the LJColour relation and create a Normal relation
- Set Field to ColourId
- Set RelatedField to ColourId
- Right-click on the LJColour relation again and create a Related Field Fixed relation
- Set RelatedField to Active
- Set Value to NoYes::Yes
- Let's add some records to the LJColour table, with both active and inactive colours
- Now, when choosing a ColourId in the Product table, notice that only the active colours (1 and 2) are returned in the lookup. ColourId 3 (Red) is not returned because Active is No
**This means that the relation between LJProduct and LJColour will only consider colours where Active is Yes. In other words, the ColourId lookup in LJProduct will only return active colours.
A real-life example for Related Field Fixed
I recently used Related Field Fixed in a real-life scenario.
We had a Parameters table, where I was asked to add two new fields: X Order Cancellation Reason Code and Y Cancellation Reason Code. Both fields allow the user to select a reason code from a Reason table. The Reason table contains the Reason Code, Not in Use, and Reason Code Action fields.
However, there were some requirements for the lookups:
- Both lookups should only return reason codes where Not in Use = No.
- X Order Cancellation Reason Code should only return reason codes where Reason Code Action = X Cancellation.
- Y Cancellation Reason Code should only return reason codes where Reason Code Action = Cancel Y Item.
Instead of overriding the lookups in X++ to apply these filters, I used Related Field Fixed conditions in the table relations.
On the Parameters table, the relations were configured as follows:
Relations
│
├── ReasonTableXOrderCancellation
│ ├── Parameters.XOrderCancellationReasonCode == ReasonTable.ReasonCode
│ ├── No == ReasonTable.NotInUse
│ └── ReasonCodeActions::XCancellation == ReasonTable.ReasonCodeAction
│
└── ReasonTableYCancellation
├── Parameters.YCancellationReasonCode == ReasonTable.ReasonCode
├── No == ReasonTable.NotInUse
└── ReasonCodeActions::CancelYItem == ReasonTable.ReasonCodeActionSummary
It's called Related Field Fixed because the fixed condition is on a field in the related table.
For Field Fixed, the fixed condition is on a field in the current table, where the relation is defined.
So the easiest way to remember it is:
Field Fixed → fixed condition on the current table
Related Field Fixed → fixed condition on the related table






















Comments
Post a Comment