# Storing ticket data

You can also store data in Custom Fields which are created by your application. This method has the advantage that your Custom Fields can be used with Ticket Filters and Triggers to create powerful automations.

If you are not yet familiar with the concept of Custom Fields in Deskpro, head over to the official documentation: <https://support.deskpro.com/en/guides/admin-guide/ticket-fields-2/custom-fields>

## How does it work?

You declare custom fields and their type in your application manifest. The custom fields are created when the application is installed and they become available through the Deskpro REST API and will also appear in the admin interface, where you can include them in Filters and Triggers.

Unlike regular custom fields, these custom fields can not be deleted while your application is installed.

Here is an example of declaring a Ticket Custom Field of type **text** with an alias and a title

```javascript
  {
      "customFields": [
        {
          "type": "text",
          "attachedTo": "ticket",
          "alias": "myField",
          "title": "My Field"
        }
      ]
  }
```

## Available Types

For in-depth coverage of Custom Fields definition, see the [customTypes](/apps-developer-guide-old/sdk/the-application-manifest/manifest-reference.md#customFields) section from the Manifest reference.

## Using the Custom Fields Client

The [Custom Fields Client](https://deskpro.github.io/apps-sdk-core/reference/CustomFieldsClient.html) allows you to read and write custom field values from the `Deskpro Object` specific to the target in which the application is running. It can work for both regular Custom Fields and Application Custom Fields.

Application Custom Fields are referred to by their `alias` which must be always defined in your application manifest. The following snippet shows you how to write and read a custom field using the Custom Fields Client:

```jsx
  // obtain a reference to the Custom Fields Client from the Application Context

  const { 
      /**
       * @see https://deskpro.github.io/apps-sdk-core/reference/CustomFieldsClient.html
       */
      customFields
  } = dpapp.context;

  // save the value of an application's custom field
  customFields.setAppField('myField', ['867-5309', 867]);

  // read the value of an application's custom field
  customFields.getAppField('myField').then(value => console.log(value));
```

For more usage examples, see this recipe: [Access Custom Fields](https://github.com/deskpro/apps-developer-guide/tree/60e4438595f571d451828dbcadd397b1022a1aae/sdk/recipes/context-object-data.md)


---

# 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://deskpro.gitbook.io/apps-developer-guide-old/sdk/storing-data/storing-ticket-data.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.
