Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

At a high level, the basic syntax to define C3.ai Type is as follows (originally from official C3.ai Type documentation here: https://developer.c3.ai/docs/7.12.17/topic/mda-types

[remix, extendable] [entity] type TypeName extends, mixes AnotherType] {
    /* comments */
    [field declaration]
    [method declaration]
}

...

Collection fields can also be used to model one-to-many and many-to-many relationships between two C3.ai Types. To do so, we sue use the Foreign Key Collection Notation, which specifies the foreign key, by which two C3.ai Types (i.e., ThisType and AnotherType) are joined. To define this annotation, use the following syntax - "fieldName :   `[AnotherType]` (fkey, key)" ; where (1) 'fkey' is a field on `AnotherType' to use as the foreign key; (2) 'key' is an optional field on ThisType, whose records should match those of the 'fkey' field on 'AnotherType' (defaults to `id` field of ThisType, if not specified). In other words, the Collection field will contain pointers to all records in AnotherType, where ThisType.key == AnotherType.fkey.

fieldName: [AnotherType] (fkey[, key])

Shown In shown in the example code and diagram below, the field bulbMeasurements, contains a list of all the SmartBulbMeasurementSeries records, where SmartBulb.id == SmartBulbMeasurements.smartBulb (e.g., a list of various measurements relevant to a SmartBulb, like temperature or power). 

Image Added

Please see the 'Foreign Key Collection and Schema Names" section in the following C3.ai Develop Documentation for more details: https://developer.c3.ai/docs/7.12.17/topic/mda-fields

...

Calculated fields are derived from other fields on a C3.ai Type. Calculated fields typically included either JavaScript code or C3.ai ExpressionEngineFunctions, and are specified as follows:

...

fieldName:

...

FieldType

...

[stored]

...

calc

...

"field_formula"

There are two types of calculated fields:

...