The GET FIELD RELATION command lets you find out the automatic/manual status of the relation starting from manyField for the current process. You can view any relation, including automatic relations set in the Structure window.
- In manyField, pass the name of theMany table field from which the relation whose status you want to find out originates. If no relation originates from the manyField field, the one et many parameters return 0, an error is returned and the system variable OK is set to 0 (see below).
- After the command is executed, the one parameter contains a value indicating whether the Many-to-One relation specified is set as automatic:
0 = There is no relation originating from manyField. Syntax error No. 16 (“The field has no relation”) is generated and the system variable OK is set to 0.
1 = The automatic/manual status of the Many-to-One relation specified is that set by the Auto Relate One option in the Relation properties of the Design environment (it has not been modified by programming).
2 = The Many-to-One relation is manual for the process.
3 = The Many-to-One relation is automatic for the process. - After the command is executed, the many parameter contains a value indicating whether the One-to-Many relation specified is set as automatic:
0 = There is no relation originating from manyField. Syntax error No. 16 (“The field has no relation”) is generated and the system variable OK is set to 0.
1 = The automatic/manual status of the One-to-Many relation specified is that set by the Auto One to Many option in the Relation properties of the Design environment (it has not been modified by programming).
2 = The One-to-Many relation is manual for the process.
3 = The One-to-Many relation is automatic for the process.
You can compare the values returned in the one and many parameters with the constants of the “Relations” theme:
Constant |
Type |
Value |
Automatic |
Longint |
3 |
Manual |
Longint |
2 |
No relation |
Longint |
0 |
Structure configuration |
Longint |
1 |
- The optional * parameter lets you “force” the reading of the current status of the relation, even if it has not been modified by programming. In other words, when you pass the * parameter, only the values 2 or 3 can be returned in the one and many parameters.
Given the following structure:
The properties of the relation linking the [Employees]Company field to the [Companies]Name field are the following:
The following code illustrates the various possibilities offered by the GET FIELD RELATION, GET AUTOMATIC RELATIONS and SET FIELD RELATION, SET AUTOMATIC RELATIONS commands along with their effects:
GET AUTOMATIC RELATIONS(one;many)
GET FIELD RELATION([Employees]Company;one;many)
GET FIELD RELATION([Employees]Company;one;many;*)
SET FIELD RELATION([Employees]Company;2;0)
GET FIELD RELATION([Employees]Company;one;many)
GET FIELD RELATION([Employees]Company;one;many;*)
SET FIELD RELATION([Employees]Company;1;0)
GET FIELD RELATION([Employees]Company;one;many)
GET FIELD RELATION([Employees]Company;one;many;*)
SET AUTOMATIC RELATIONS(True;True)
GET AUTOMATIC RELATIONS(one;many)
GET FIELD RELATION([Employees]Company;one;many)
GET FIELD RELATION([Employees]Company;one;many;*)