Home
/
Desk
/
JavaScript
/
Custom fields

Ticket fields

With Ticket fields, you can save additional information of a ticket, and tickets can be classified in detail by utilizing the saved information.

Note: Refer to Prerequisite before saving additional ticket information.


Store additional information of a ticket

Use the ticket.setCustomFields() method to save additional information of a ticket. Information must consist of a field and its value, and only the field already registered in Settings > Ticket fields on the Sendbird Dashboard can be used.

Light Color Skin
Copy
const customFields = {
    'Product type': 'Desk',
    'line': '3'
};

ticket.setCustomFields(customFields, (ticket, error) => {
    if (error) {
        // Handle error.
    }
    // The additional information of the ticket is saved.
    // Some fields can be ignored if they aren't registered on the dashboard.
    // Values aren't saved if they don't match the data type of their fields.
});

Note: You can store additional information of a ticket when creating a ticket.


Use a ticket field as a search filter

You can filter tickets by adding a ticket field as a search filter to the getOpenedList() and getClosedList(). Tickets that have a value of the selected field will appear on the ticket list.

Light Color Skin
Copy
const customFieldFilter = {'subject' : 'doggy_doggy'};
Ticket.getOpenedList(OFFSET, customFieldFilter, (openedTickets, error) => {
    if (error) {
        // Handle error.
    }

    const tickets = openedTickets;
    // offset += tickets.length; for the next tickets.
    // Implement your code to display the ticket list.
});