Apps Developer Guide (Old)
  • Introduction
  • Create your first app in 4 easy steps
  • Overview
    • How does it work ?
    • Documentation
    • Deskpro Apps Tool
  • SDK
    • The Application Manifest
      • Manifest Reference
    • Storing data
      • Storing ticket data
    • Accessing the Deskpro REST API
    • Accessing remote services
    • The Application Installer
    • Application Contexts
      • ContextDataObject Reference
    • Events
  • Guides
    • Create an Oauth2 integration
    • Using an API Key to read data
  • Application Context
    • Get the authenticated user
    • Access Custom Fields
    • Interacting with the Host UI Container
  • Application Container
    • How do I badge my app icon
  • HTTP
    • How do I use a remote web service
  • OAuth2
    • How do I customize OAuth2 requests
  • UI Patterns
    • How do I split my app into different screens
Powered by GitBook
On this page
  • How does it work?
  • Available Types
  • Using the Custom Fields Client
  1. SDK
  2. Storing data

Storing ticket data

PreviousStoring dataNextAccessing the Deskpro REST API

Last updated 6 years ago

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:

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

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

Available Types

Using the Custom Fields Client

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:

  // 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 in-depth coverage of Custom Fields definition, see the section from the Manifest reference.

The 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.

For more usage examples, see this recipe:

https://support.deskpro.com/en/guides/admin-guide/ticket-fields-2/custom-fields
Custom Fields Client
Access Custom Fields
customTypes