version 2004.1
AP Create relation (sourceTableNum; sourceFieldNum; destTableNum; destFieldNum) Longint
| Parameter | Type | Description | |
| sourceTableNum | Longint | Number of the table from which the relation starts | |
| sourceFieldNum | Longint | Number of the field from which the relation starts | |
| destTableNum | Longint | Number of the table where the relation arrives | |
| destFieldNum | Longint | Number of the field where the relation arrives | |
| Function result | Longint | Error code (0=no error) |
Description
The AP Create relation command allows you to create a relation between two tables. In sourceTableNum and sourceFieldNum, pass the numbers of the source table and field, and in destTableNum and destFieldNum, pass the numbers of the destination table and field.
The relation is created with standard properties. You can use 4D relation management commands to get or set these properties.
If the operation is completed successfully, the function returns 0. Otherwise, it returns an error code.
Note: This command does not work when it is executed from a compiled application that has been merged with 4D Runtime Volume License.
Example
This example creates a relation from table 1 to table 2:
C_LONGINT($SourceTable;$SourceField;$DestTable;$DestField) $SourceTable:=1 $SourceField:=2 $DestTable:=2 $DestField:=2 $error:=AP Create relation ($SourceTable;$SourceField;$DestTable;$DestField)