DataClassAttribute
Dataclass attributes are available as properties of their respective classes. Par exemple :
nameAttribute:=ds.Company.name //référence à un attribut de classe
revenuesAttribute:=ds.Company["revenues"] //méthode alternative
This code assigns to nameAttribute and revenuesAttribute references to the name and revenues attributes of the Company class. Cette syntaxe ne retourne PAS les valeurs contenues dans l'attribut, mais retourne plutôt des références aux attributs eux-mêmes. To handle values, you need to go through Entities.
DataClassAttribute
objects have properties that you can read to get information about your dataclass attributes.
Dataclass attribute objects can be modified, but the underlying database structure will not be altered.
Sommaire
.autoFilled : Booléen contains True if the attribute value is automatically filled by 4D |
.fieldNumber : Entier contains the internal 4D field number of the attribute |
.fieldType : Integer contains the 4D database type of the attribute |
.indexed : Booléen contains True if there is a B-tree or a Cluster B-tree index on the attribute |
.inverseName : Text returns the name of the attribute which is at the other side of the relation |
.keyWordIndexed : Boolean contains True if there is a keyword index on the attribute |
.kind : Text returns the category of the attribute |
.mandatory : Boolean contains True if Null value input is rejected for the attribute |
.name : Text retourne le nom de l'objet |
.relatedDataClass : Text retourne le nom de la dataclass associée à l'attribut |
.type : Texte contient le type de valeur conceptuelle de l'attribut |
.unique : Booléen contient True si la valeur d'attribut doit être unique |
.autoFilled
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.autoFilled : Booléen
Description
The .autoFilled
property contains True if the attribute value is automatically filled by 4D. This property corresponds to the following 4D field properties:
- "Autoincrement", for numeric type fields
- "Auto UUID", for UUID (alpha type) fields.
This property is not returned if .kind
= "relatedEntity" or "relatedEntities".
For generic programming, you can use Bool(dataClassAttribute.autoFilled) to get a valid value (false) even if
.autoFilled
is not returned.
.fieldNumber
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.fieldNumber : Entier
Description
The .fieldNumber
property contains the internal 4D field number of the attribute.
This property is not returned if .kind
= "relatedEntity" or "relatedEntities".
For generic programming, you can use Num(dataClassAttribute.fieldNumber) to get a valid value (0) even if
.fieldNumber
is not returned.
.fieldType
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.fieldType : Integer
Description
The .fieldType
property contains the 4D database type of the attribute. It depends on the attribute kind (see .kind
).
Valeurs possibles :
dataClassAttribute.kind | fieldType | Commentaire |
---|---|---|
storage | Corresponding 4D field type | Voir la commande Type |
relatedEntity | 38 (Is object) | |
relatedEntities | 42 (Is collection) |
.indexed
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.indexed : Booléen
Description
The .indexed
property contains True if there is a B-tree or a Cluster B-tree index on the attribute.
This property is not returned if .kind
= "relatedEntity" or "relatedEntities".
For generic programming, you can use Bool(dataClassAttribute.indexed) to get a valid value (false) even if
.indexed
is not returned.
.inverseName
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.inverseName : Text
Description
The .inverseName
property returns the name of the attribute which is at the other side of the relation.
This property is not returned if .kind
= "storage". It must be of the "relatedEntity" or "relatedEntities" kind.
For generic programming, you can use String(dataClassAttribute.inverseName) to get a valid value ("") even if
.inverseName
is not returned.
.keyWordIndexed
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.keyWordIndexed : Boolean
Description
The .keyWordIndexed
property contains True if there is a keyword index on the attribute.
This property is not returned if .kind
= "relatedEntity" or "relatedEntities".
For generic programming, you can use Bool(dataClassAttribute.keyWordIndexed) to get a valid value (false) even if
.keyWordIndexed
is not returned.
.kind
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.kind : Text
Description
The .kind
property returns the category of the attribute. Returned value can be one of the following:
- "storage": storage (or scalar) attribute, i.e. attribute storing a value, not a reference to another attribute
- "relatedEntity": N -> 1 relation attribute (reference to an entity)
- "relatedEntities": 1 -> N relation attribute (reference to an entity selection)
Exemple
Given the following table and relation:
var $attKind : Text
$attKind:=ds.Employee.lastname.kind //$attKind="storage"
$attKind:=ds.Employee.manager.kind //$attKind="relatedEntity"
$attKind:=ds.Employee.directReports.kind //$attKind="relatedEntities"
.mandatory
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.mandatory : Boolean
Description
The .mandatory
property contains True if Null value input is rejected for the attribute.
This property is not returned if .kind
= "relatedEntity" or "relatedEntities".
For generic programming, you can use Bool(dataClassAttribute.mandatory) to get a valid value (false) even if
.mandatory
is not returned. Warning: This property corresponds to the "Reject NULL value input" field property at the 4D database level. It is unrelated to the existing "Mandatory" property which is a data entry control option for a table.
.name
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.name : Text
Description
La propriété .name
retourne le nom de l'objet dataClassAttribute
en chaîne.
Exemple
var $attName : Text
$attName:=ds.Employee.lastname.name //$attName="lastname"
.relatedDataClass
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.relatedDataClass : Text
Description
Cette propriété n'est disponible qu'avec les attributs de la propriété "relatedEntity" ou "relatedEntities"
.kind
.
La propriété .relatedDataClass
retourne le nom de la dataclass associée à l'attribut.
Exemple
Considérons les tableaux et relations suivants :
var $relClass1; $relClassN : Text
$relClass1:=ds.Employee.employer.relatedDataClass //$relClass1="Company"
$relClassN:=ds.Employee.directReports.relatedDataClass //$relClassN="Employee"
.type
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.type : Texte
Description
La propriété .type
contient le type de valeur conceptuelle de l'attribut, utile pour la programmation générique.
Le type de valeur conceptuelle dépend de l'attribut .kind
.
Valeurs possibles :
dataClassAttribute.kind | type | Commentaire |
---|---|---|
storage | "number", "date", "object", "bool", "image", ou "string" | "nombre" est rertourné pour tous les types numériques, y compris la durée. "string" est retourné pour les types de champs uuid, alpha et text |
relatedEntity | nom de dataClass associé | Ex : "Companies" |
relatedEntities | nom de dataClass associé + suffixe "Selection" | Ex : "EmployeeSelection" |
.unique
Historique
Version | Modifications |
---|---|
v17 R5 | Ajoutées |
.unique : Booléen
Description
La propriété .unique
contient True si la valeur d'attribut doit être unique. Cette propriété correspond à la propriété de champ 4D "Unique".
This property is not returned if .kind
= "relatedEntity" or "relatedEntities".
Pour la programmation générique, vous pouvez utiliser Bool (dataClassAttribute.unique) pour obtenir une valeur valide (false) même si
.unique
n'est pas retourné.