Dynamics 365 Business Central: Can we extend TableRelation Property through a table extension??? (Yes, But…)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to briefly talk about whether we can extend TableRelation Property through a table extension.

In conclusion, yes we can, but with some limitations.

First review what TableRelation Property is.
TableRelation Property: Sets up a lookup into another table. The following syntax is valid for the TableRelation property.

TableRelation = <TableName>[.<FieldName>] [WHERE(<TableFilters>)] |
[IF(<Conditions>) <TableName>[.<FieldName>] [WHERE(<TableFilters>)] ELSE <TableRelation>]
<Conditions> ::= <TableFilters>
<TableFilters>::= <TableFilter> {,<TableFilter>}
<TableFilter>::= <DestinationFieldName>=CONST(<FieldConst>) | FIELD(<SourceFieldName>)

The TableRelation property lets you establish lookups into other tables. For example, on the Item card you can select a vendor from who you usually purchase an item.

This is done through a table relationship.

Next, let’s look at an simple example. We have two fields, “Salesperson Code” and “Address 2” in the Customer table.

“Salesperson Code” is set the TableRelation Property by default, “Address 2” is not.

Create a table extension, each adding a new TableRelation property.
TableRelation = Vendor;

What will happen then?
For “Salesperson Code”, the extended TableReleation property is not in effect and remains the same.

For “Address 2”, the extended TableReleation property is in effect and we can open the related vendor table.

So we can only extend TableRelation Property for the field that is not set TableRelation Property?

Not exactly, let’s look at another example.
In the sales order line, “No.” will be related to a different table depending on the value of Type.

This mainly uses the IF(<Conditions>) of the TableRelation Property.

What happens if I add a new Sales Line Type and then add a new Condition?
For example,

PS: We need to show the real Type on the page, the system is showing a variable by default. (I’ll explain this in more detail next time if I have time)

Let’s test it again.

When Type is Vendor, we can select the record of vendor from “No.”. The extended TableReleation property is in effect.

Test Video:

Why? We can find the answer in MS Docs.

The TableRelation property can be modified through a table extension. Modifications to the TableRelation are additive and evaluated after the existing value.

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-tablerelation-property

So when proposing in the project, always be aware that not all can be done for the extension of TableRelation property, and we may have to create a new field to handle these special needs. This definitely makes customization more complicated. Well, I hope this helps, go ahead and try it out.

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL