Skip to main content
Version: v20 BETA

DataClassAttribute

Dataclass attributes are available as properties of their respective classes. For example:

 nameAttribute:=ds.Company.name //reference to class attribute
revenuesAttribute:=ds.Company["revenues"] //alternate way

This code assigns to nameAttribute and revenuesAttribute references to the name and revenues attributes of the Company class. This syntax does NOT return values held inside of the attribute, but instead returns references to the attributes themselves. 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.

Summary

.autoFilled : Boolean    contains True if the attribute value is automatically filled by 4D
.exposed : Boolean    true if the attribute is exposed in REST
.fieldNumber : Integer    contains the internal 4D field number of the attribute
.fieldType : Integer    contains the 4D database type of the attribute
.indexed : Boolean    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    returns the name of the dataClassAttribute object as string
.path : Text    returns the path of an alias attribute based upon a relation
.readOnly : Boolean    true if the attribute is read-only
.relatedDataClass : Text    returns the name of the dataclass related to the attribute
.type : Text    contains the conceptual value type of the attribute
.unique : Boolean    contains True if the attribute value must be unique

.autoFilled

History
VersionChanges
v17 R5Added

.autoFilled : Boolean

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.

.exposed

History
VersionChanges
v19 R3Added

.exposed : Boolean

Description

The .exposed property is true if the attribute is exposed in REST.

See also

DataClass.getInfo()

.fieldNumber

History
VersionChanges
v17 R5Added

.fieldNumber : Integer

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

History
VersionChanges
v19 R4Support of alias attributes
v19 R3Support of computed attributes

.fieldType : Integer

Description

The .fieldType property contains the 4D database type of the attribute. It depends on the attribute kind (see .kind).

Possible values:

dataClassAttribute.kindfieldType
storageCorresponding 4D field type, see Value type
relatedEntity38 (Is object)
relatedEntities42 (Is collection)
calculated
  • scalar: corresponding 4D field type, see Value type
  • entity: 38 (Is object)
  • entity selection: 42 (Is collection)
  • alias
  • scalar: corresponding 4D field type, see Value type
  • entity: 38 (Is object)
  • entity selection: 42 (Is collection)
  • See also

    .type

    .indexed

    History
    VersionChanges
    v17 R5Added

    .indexed : Boolean

    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

    History
    VersionChanges
    v17 R5Added

    .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

    History
    VersionChanges
    v17 R5Added

    .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

    History
    VersionChanges
    v19 R4Added "alias"
    v19 R3Added "calculated"

    .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
    • "calculated": computed attribute, i.e. defined through a get function
    • "alias": attribute built upon another attribute
    • "relatedEntity": N -> 1 relation attribute (reference to an entity)
    • "relatedEntities": 1 -> N relation attribute (reference to an entity selection)

    Example

    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

    History
    VersionChanges
    v17 R5Added

    .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

    History
    VersionChanges
    v17 R5Added

    .name : Text

    Description

    The .name property returns the name of the dataClassAttribute object as string.

    Example

     var $attName : Text
    $attName:=ds.Employee.lastname.name //$attName="lastname"

    .path

    History
    VersionChanges
    v19 R4Added

    .path : Text

    Description

    The .path property returns the path of an alias attribute based upon a relation.

    Example

     var $path : Text
    $path:=ds.Teacher.students.path //$path="courses.student"

    .readOnly

    History
    VersionChanges
    v19 R3Added

    .readOnly : Boolean

    Description

    The .readOnly property is true if the attribute is read-only.

    For example, computed attributes without set function are read-only.

    .relatedDataClass

    History
    VersionChanges
    v17 R5Added

    .relatedDataClass : Text

    Description

    This property is only available with attributes of the "relatedEntity" or "relatedEntities" .kind property.

    The .relatedDataClass property returns the name of the dataclass related to the attribute.

    Example

    Given the following tables and relations:

     var $relClass1; $relClassN : Text
    $relClass1:=ds.Employee.employer.relatedDataClass //$relClass1="Company"
    $relClassN:=ds.Employee.directReports.relatedDataClass //$relClassN="Employee"

    .type

    History
    VersionChanges
    v19 R3Support of computed attributes

    .type : Text

    Description

    The .type property contains the conceptual value type of the attribute, useful for generic programming.

    The conceptual value type depends on the attribute .kind.

    Possible values:

    dataClassAttribute.kindtypeComment
    storage"blob", "bool", "date", "image", "number", "object", or "string""number" is returned for any numeric types including duration. "string" is returned for uuid, alpha and text field types. "blob" attributes are blob objects, they are handled using the Blob class.
    relatedEntityrelated dataClass nameEx: "Companies"
    relatedEntitiesrelated dataClass name + "Selection" suffixEx: "EmployeeSelection"
    calculated
  • storage: type ("blob", "number", etc.)
  • entity: dataClass name
  • entity selection: dataClass name + "Selection"
  • See also

    .fieldType

    .unique

    History
    VersionChanges
    v17 R5Added

    .unique : Boolean

    Description

    The .unique property contains True if the attribute value must be unique. This property corresponds to the "Unique" 4D field property.

    This property is not returned if .kind = "relatedEntity" or "relatedEntities".

    For generic programming, you can use Bool(dataClassAttribute.unique) to get a valid value (false) even if .unique is not returned.