Hi Readers.
Today, I would like to share a development error handling about TableRelation Property.
Validation Results
The following field must be included into the table’s primary key: Field: Name Table: Vendor
![](https://yzhums.com/wp-content/uploads/2022/02/image-109-1024x517.png)
I was asked this question recently. This is a very basic question.
As you might know, using TableRelation Property is very convenient when you want to set up a lookup into another table.
TableRelation Property: Sets up a lookup into another table.
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.
![](https://yzhums.com/wp-content/uploads/2022/02/image-111-1024x517.png)
![](https://yzhums.com/wp-content/uploads/2022/02/image-110-1024x537.png)
Why does this problem occur when adding the TableRelation property in the extension?
Let’s continue to see.
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>)
You can define to specific field in TableRelation property .
For example: TableRelation = Vendor.”No.”;
![](https://yzhums.com/wp-content/uploads/2022/02/image-112.png)
TableRelation = Vendor.Name;
![](https://yzhums.com/wp-content/uploads/2022/02/image-114.png)
And then “TableRelation = Vendor.Name” will cause this problem. Becuase the “Name” field is not included into the primary key of Vendor table. In other words, a table relation cannot be made to a field which is not part of the primary key in a table.
![](https://yzhums.com/wp-content/uploads/2022/02/image-115.png)
So what should we do if we still want to display the name, not the number?
There are several ways.
1. Using ValidateTableRelation Property: Sets whether to validate a table relationship.
More details: How to enter any value in a TableRelation field (Without validating the table relationship)
ValidateTableRelation = false;
![](https://yzhums.com/wp-content/uploads/2022/02/image-116.png)
Test Video:
PS: You can find a reference in User Setup page.
![](https://yzhums.com/wp-content/uploads/2022/02/image-118-1024x509.png)
![](https://yzhums.com/wp-content/uploads/2022/02/image-117.png)
2. Using OnLookup (Field) Trigger and Page.RunModal() Method
This method is somewhat different from TableRelation in user operation, requiring you to select the data you need in a new pop-up page.
![](https://yzhums.com/wp-content/uploads/2022/02/image-119-1024x612.png)
Test video:
3. Add both Number field and Name field, and update the Name field when Number is validated.
![](https://yzhums.com/wp-content/uploads/2022/02/image-121.png)
Test Video:
PS: Similar to the above, you can also define the name as FlowField.
![](https://yzhums.com/wp-content/uploads/2022/02/image-122.png)
END
Hope this will help.
Thanks for reading.
ZHU
コメント