# Types

### Simple Types

The[ Linx plugin](/reference/plugins/linx.md) contains all Simple Types. These include:

* [Boolean](/reference/plugins/linx/content/boolean.md)
* [Byte](/reference/plugins/linx/content/byte.md)
* [DateTime](/reference/plugins/linx/content/datetime.md)
* [Decimal](/reference/plugins/linx/content/decimal.md)
* [Double](/reference/plugins/linx/content/double.md)
* [Integer](/reference/plugins/linx/content/integer.md)
* [String](/reference/plugins/linx/content/string.md)

Use a Simple Type to create a variable in a Function by:

1. Dragging the type from the plugins panel onto the body of a Function.
2. Setting the *Value* property.

![Using Simple Types](/files/hX2fAIw2VTv56jlbfnXp)

***

### Complex Types

In the Linx Designer, Complex Types are just referred to as *Types*.

A *Type* in Linx works just like a JSON object. *Types* contain collections of named properties. Each property represents a *Simple Type*, a complex *Type*, or a *List*.

**Creating a Complex Type**

1. Click the *Type* button in the toolbar to add a type to your solution.
2. Set a name for the *Type* in the Properties panel.
3. Add properties to the *Type* using the *Type Editor*:
   * Add a name for each property in the *Name* column.
   * Select the property type in the *Type* column dropdown.

![Using Complex Types](/files/IBwV4WIxOd6s4PSpMSLw)

This example shows a \*Type\* with four properties (Address is of type 'Type\_Address', Children is a List of type 'Type\_Child', DOB is of type DateTime, and Name is of type String)

Here is a JSON representation of the Type\_Person type:

{% code overflow="wrap" %}

```json
{ "Person": { "Address": { "Street": "", "City": "", "POCode": "" }, "Children": [], "DOB": "", "Name": "" } }
```

{% endcode %}

## Using a Complex Type

1. Drag the Type from the Solution Explorer onto the Function body.
2. By default, the type is instantiated as empty using squiggly brackets `{}`, but its properties are not initialized and default to null.

![Instantiated, empty type](/files/APiZSflq4pkq0CHWpRxa)

3. Set values for Type properties by either:
   * Launching the Values Editor to add values.

![Drag the type into the Function](/files/DaZophGhpTrAW0bP7EoI)

```
*   Using a[ SetValue](../reference/plugins/linx/content/setvalue.md) function.
```

<div align="left"><img src="/files/FNz7Lo7tlv0PRGRpYmOP" alt="Using a SetValue to set a Type property"></div>

***

### Lists

Lists can be of any simple or complex type.

#### Creating a List

1. Drag a [List](/reference/plugins/linx/content/genericlist.md) from the Linx plugin onto the Function body.
2. An empty List will be initialized using square brackets `[]`.
3. Choose the List type in the property dropdown (it defaults to String).

![Select a List type](/files/563zXuC87uu7zuY8gCHs)

#### Adding Items to Lists

Add items to Lists by either:

1. Launching the List editor.

![Using a List](/files/70MFZESCvrv1Yaif1L6O)

1. Dragging an[ AddToList](/reference/plugins/linx/content/addtolist.md) function into the Function.
2. Selecting the List and value to add in the AddToList properties.

![Adding to a List](/files/FosngjFN17MHdKDeqLC2)

Other functions to manipulate the list are available in the Linx plugin.

![List Functions](/files/Vy5sJFWM1MQlCRTqXWZw)

***

### Assignment Errors

A common problem is caused by the attempt to assign values to NULL elements.

1. To set a value for a property of a complex type, the type cannot be null.

   ![Attempting to set an uninstantiated type causes an 'Object reference not set to an instance of an object' error](/files/sN3Yu4WIrd2ihw9ko1Yx)
2. Instantiate a Complex type inside another one with `{"PropertyName":{}}`.

   <div align="left"><img src="/files/uBkjijqFMTA3LwZvSBuq" alt="Complex types that are properties of other complex types must be instantiated before they can be used"></div>
3. Lists must be instantiated before they can be added to.

   ![Attempting to add items to an uninstantiated List causes a 'Cannot add to list as it is null' error](/files/prVS9ZeX0HNPh6sb0mDP)
4. Instantiate Lists that are properties of complex types with `{"PropertyName":[]}`.

   <div align="left"><img src="/files/rLnS3btbGfFFQ8EUQu5j" alt="Lists that are properties of complex types must be instantiated before they can be used"></div>

***

### Tutorial Video

{% embed url="<https://youtu.be/LwHlp1UAwOk>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.linx.software/main-concepts/types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
