Access Custom Fields

The Custom Fields feature give you another way of storing application data which is associated with the application context's Deskpro Object.

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

You access Custom Fields through a CustomFieldsClient, which is made available via the customFields property of the application context:

    const { customFields } = this.props.dpapp.context;
    customFields.getField('myFieldId').then(value => console.log(value));

For setting the value of a field:

    const { customFields } = this.props.dpapp.context;
    customFields.setField('myFieldId', myValue).then(response => console.log(response.body));

The methods above allow you to retrieve the value of any custom field by its id. For custom fields which are created by your application and which are referred to by their alias, the custom fields client offers a set of similar methods.

If your application is adding new custom fields and you need to access them use the following method for reading:

    const { customFields } = this.props.dpapp.context;
    customFields.getAppField('myAlias').then(value => console.log(value));

For setting the value of a field:

    const { customFields } = this.props.dpapp.context;
    customFields.setAppField('myAlias', myValue).then(response => console.log(response.body));

Last updated