# Class

## Getting Started

Navigate to your **Workspace > Apps** and click on the gear icon<img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBCeOhqzSg8dBSFcJSA%2F-MBCo7T7BtG64Zwffv31%2Ffa-cog.png?alt=media&#x26;token=7b190f6b-19e5-4dea-8eaa-3bf0e53fa641" alt="" data-size="line"> to activate the configuration mode of your applications. Next, click on the gear icon<img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBCeOhqzSg8dBSFcJSA%2F-MBCo7T7BtG64Zwffv31%2Ffa-cog.png?alt=media&#x26;token=7b190f6b-19e5-4dea-8eaa-3bf0e53fa641" alt="" data-size="line"> of the application you wish to configure. In the **Data** section you click on **Classes** to access the Class Designer.

![Class designer: Accessing the class designer](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBG89sfc5p_vTBzIR1t%2F-MBG8CzKXvvk_94qzMgo%2FOpen_Class_Designer-min.gif?alt=media\&token=d5dca81b-2242-458a-8f23-0ba0facd1cc7)

Next, select **New Class** in the toolbar of the Class Designer and choose a **Base Class** for the new class.

{% hint style="info" %}
Base classes allow your class to be preconfigured with some properties through inheritance. Custom base classes can be created by defining a class as an [Abstract Class](#class-type).
{% endhint %}

![Class designer: Creating a class](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBG89sfc5p_vTBzIR1t%2F-MBG8QcNW084nEdQM2iA%2FCreate_Class-min.gif?alt=media\&token=8dee782a-ce8a-44b8-97c7-dab864e6c092)

A class contains **Common**, **Mapping**, **Advanced** and **Permissions** configurations. These properties are used to define how the class is stored and how it can be used in your application.

## Common Attributes

The Common section contains general properties of a class. In this section, you can specify how the class is presented in your application by setting the name, description and icon. The class type can also be defined based on how the class will be used in the application.

![Common attributes for a class](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBFc4IHx3nvPIPXgw3o%2F-MBFf3shrCnKFiq8Cx9s%2FClass-Common-Attributes.png?alt=media\&token=07ccc484-3adc-4c24-a407-7c397141d64a)

### Key

The class key acts as a unique identifier for the class in your application. This allows the class to be identified by other designers on the platform - e.g. the [Query Designer](https://docs.tivity.one/building-an-application/data/query-data).

{% hint style="info" %}
The **Key** field is compulsory when creating a class.
{% endhint %}

### Name

The class name is a user-friendly name to help users easily identify a class. It can be defined in several languages by selecting the globe icon (on the right side of the text box).

{% hint style="info" %}
The **Name** field is compulsory when creating a class.
{% endhint %}

### Description

The class description provides additional information that can be used as help text.

### Icon

An image can be assigned to the class to further customize it.

### Color

This defines the color assigned to the class icon in the class designer.

![Different class icon colors in class designer](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBIi22NccPviHotGRVV%2F-MBIkIPk8ad8AMIMMJVc%2Fimage.png?alt=media\&token=2dc884a3-67d1-4b69-88f7-7758f191946f)

### Class Type

The class type specifies how the application should treat the class. The options available to customize the class type are **Is Abstract**, **Is Independent** and **Autosave**.

**Is Abstract**

An abstract class is one that cannot be instantiated. It can be used as a **Base Class** when during class creation, allowing the new class to inherit all its properties.

{% hint style="success" %}
Example: An abstract class can be created for new classes to use as Base Class - inheriting preconfigured fields such as **Created Date**, **Modified Date** and **Deleted Date**.
{% endhint %}

**Is Independent**

An independent class can exist on its own without any dependency on other classes in the application. This is closely related to how links work on the platform.

**Autosave**

By activating autosave, objects of the class are automatically saved to the database by the application when created or edited.

{% hint style="danger" %}
In case a class is not defined as **Autosave**, the application layouts should include a button to manually ensure that data is being saved to the database.
{% endhint %}

## Mapping Attributes

Classes are stored as tables in the database. The Mapping section defines how the class is identified on a database level by the platform and your application.

![Mapping attributes for a class](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBFc4IHx3nvPIPXgw3o%2F-MBFfFP4265f76PycYOK%2Fimage.png?alt=media\&token=ff6c45dd-60e4-4ff1-b8fc-b29531916f0d)

### **Key**

The mapping key specifies the name of the table for your class in the database. The platform caters for two different scenarios when mapping a class.

**Creating applications from scratch**

In this scenario, a new application with new classes is being created. The tables are generated when the classes are defined and saved in the Class Designer.

**Legacy systems**

In this scenario, an application is using a class that reads data from an existing database. This approach allows you to model existing (legacy) systems on the platform.

## Advanced Attributes

The Advanced section allows you to control how the platform and the application uses the class.

![Advanced attributes for a class](https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HTRblOKav_qm4KEx6%2F-MBFc4IHx3nvPIPXgw3o%2F-MBFfUc4we82zup_I8AU%2Fimage.png?alt=media\&token=6e22f981-43e8-4747-ae2f-8d50ccd75b15)

### Controller

This field allows you to specify additional logic related to your class by linking it to a controller file that contains the required code.

{% hint style="danger" %}
Generally, the controller should be left as **Default** and only customized in unique circumstances.
{% endhint %}

### Document Source

Classes can be initialized from a document on the platform by specifying a document source.

### Default Sorting Field

This field defines which class field should be used to sort the elements of the class in a list.

### Sorting Direction

The elements can be sorted in **ascending** or **descending** order based on this configuration.

## Permissions

This section allows you to specify which users or user groups can access the elements of this class or its data fields for reading or manipulating.
