How to customize the Tickets module for the ASAP Flutter SDK?

How to customize the Tickets module for the ASAP Flutter SDK?

The Ticket module in Zoho Desk manages all customer support requests and inquiries. Each ticket includes the customer's name, email address, phone number, and issue description. The Ticket module also offers automated ticket assignment, escalation, and SLA management to help support teams streamline their workflow and assist customers efficiently.

These methods help configure the Submit Ticket form on the ASAP help widget:

Custom-configuring ticket actions

Users can perform various actions, including replying to, commenting on, and closing tickets.

The following method helps you define which actions must be allowed and which must be disallowed when users access the ticket submission screen on the ASAP help widget.

  1. import 'package:zohodesk_portal_ticket/zohodesk_portal_ticket.dart' show ZohodeskPortalTicket;
  2. import 'package:zohodesk_portal_ticket/data/zdp_ticket_configuration.dart' show ZDPTicketConfiguration;
  3.  
  4. void setupTicketConfiguration() {
  5.   ZDPTicketConfiguration configuration = ZDPTicketConfiguration();
  6.   configuration.isReplyAllowed = true;
  7.   ZohodeskPortalTicket.setConfiguration(configuration);
  8. }
Info
Here, 
  1. configuration.isReplyAllowed = false; disables the ticket reply option
  2. configuration.isReplyAllowed = true; enables the ticket reply option
Refer to the table below for all the ticket module configurations:

Method name
Functional description
Default status
isReplyAllowed
To hide the ticket reply option.
Enabled
isCommentAllowed
To hide the ticket comment option.
Enabled
isTicketUpdateAllowed
To hide the ticket update option.
Enabled
isCommentEditAllowed
To hide the ticket comment edit option.
Enabled
isCommentDeleteAllowed
To hide the ticket comment delete option.
Enabled
isAddTicketAllowed
To hide the add ticket option on the ticket list screen.
Enabled
isHappinessThreadAllowed
To hide the ticket happiness thread.
Enabled
isTicketPropertiesAllowed
To hide the ticket properties section.
Enabled
isTicketChannelAllowed
To hide the ticket channel icon information.
Enabled
isTicketDetailSearchAllowed
To hide the search option in the ticket detail screen.
Enabled

Customizing the Field Visibility in the Submit Ticket Form:

The ZohodeskPortalSubmitTicket.setTicketsFieldsListTobeShown() method lets you control which fields appear in the Submit Ticket form within your ASAP help widget. By specifying the required fields, you can customize the form’s layout and improve the user experience.


After you include this method, the form displays only the fields you passed.

This method takes a list of ZDVisibleTicketField objects, the object includes:

  1. The department ID (mandatory) – Ensures correct mapping of fields to the respective department.
  2. The layout ID – Specifies the layout for which the fields should be configured.
  3. A list of field API names – Defines which fields should be shown in the ticket form.
  1. import 'package:zohodesk_portal_submit_ticket/zohodesk_portal_submit_ticket.dart' show ZohodeskPortalSubmitTicket;
  2. import 'package:zohodesk_portal_submit_ticket/common/ZDVisibleTicketField.dart' show ZDVisibleTicketField;
  3.  
  4. void setTicketsFieldsListTobeShown(){
  5.   ZohodeskPortalSubmitTicket.setTicketsFieldsListTobeShown(
  6.     [
  7.       ZDVisibleTicketField(
  8.         departmentId: 'departmentId',
  9.         layoutId: 'layoutId',
  10.         fieldNames: [
  11.           "fieldApiName",
  12.         ]
  13.       )
  14.     ]
  15.   );
  16. }
Notes
Please note that the mandatory fields cannot be hidden even if you do not pass their names in the above method.

Pre-filling the ticket fields in the Submit Ticket form: 

The preFillTicketFields() method allows you to prepopulate fields in the Submit Ticket form with predefined values. This is useful for automatically setting default values, reducing manual input, and ensuring mandatory fields are filled before submission.


Additionally, this method can be used to hide mandatory fields in the form. A mandatory field can only be hidden if it has a predefined value; this ensures that even though the user doesn’t see the field, it still contains valid data required for ticket submission.

  1. Pre-filled fields with default values, such as auto-generated IDs or system data.
  2. Ensure mandatory fields have values while keeping them hidden from users.
  3. Control field editability, some fields can be locked (non-editable), while others remain user-modifiable.

Method Implementation

To pre-fill ticket fields, create a list of ZDCustomizedTicketForm objects.


Each form should include:

  • departmentId – The ID of the department where these fields should be applied.
  • layoutId – The layout ID associated with the ticket form.
  • customizedTicketFields – A list of ZDCustomizedTicketField objects, specifying the field name, value, and editability.

Each ZDCustomizedTicketField object contains three main properties:

  1. fieldAPIName (string): The API name of the ticket field. You can retrieve the API name of each field using the getTicketFields() method.
  2. fieldValue - The value assigned to the field (formatted based on field type).
  1. For multi-select fields, pass the values as a list of strings.
  2. Pass one of the values allowed as a string for pick list fields.
  3. For date fields, pass the value as a string in the dd-MM-yyyy format.
  4. For date-time fields, pass the value as a string in the dd-MM-yyyy HH-mm format.
  5. For boolean fields, pass a Boolean value.
  6. For all other field types, pass the values as string objects.
  7. Make sure that the values you pass adhere to the max length and decimal restrictions defined for the field.
  1. isEditable (Boolean) - A key that defines if the value in the field is editable or not.
  1. import 'package:zohodesk_portal_submit_ticket/zohodesk_portal_submit_ticket.dart' show ZohodeskPortalSubmitTicket;
  2. import 'package:zohodesk_portal_submit_ticket/common/ZDCustomizedTicketForm.dart' show ZDCustomizedTicketForm;
  3. import 'package:zohodesk_portal_submit_ticket/common/ZDCustomizedTicketField.dart' show ZDCustomizedTicketField;
  4.  
  5. void preFillTicketFields(){
  6.   ZohodeskPortalSubmitTicket.preFillTicketFields(
  7.     [
  8.       ZDCustomizedTicketForm(
  9.         departmentId: "departmentId",
  10.         layoutId: "layoutId",
  11.         customizedTicketFields: [
  12.           ZDCustomizedTicketField( fieldName: 'fieldApiName', value: 'fieldValue')
  13.         ],
  14.       ),
  15.     ],
  16.   );
  17. }

To fetch the Department ID for Ticket operations:

The Department ID is essential for various ticket operations, including:

  1. Pre-filling Ticket Fields – Ensuring default values are assigned.
  2. Showing Visible Ticket Fields – Controlling which fields are displayed in the ticket form.

The getDepartments() method retrieves available departments, providing the necessary Department ID for these operations.

  1. import 'package:zohodesk_portal_apikit/common/ZDResponseCallback.dart';
  2. import 'package:zohodesk_portal_apikit/model/ZDDepartment.dart';
  3. import 'package:zohodesk_portal_apikit/zohodesk_portal_apikit.dart'
  4.     show ZohodeskPortalApikit;
  5.  
  6. class DepartmentsDownloader implements DepartmentsCallback{
  7.   @override
  8.   onDepartmentsFetch(List<ZDDepartment> departments) {
  9.     //departments fetched successfully
  10.   }
  11.  
  12.   @override
  13.   onError(String errorMessage) {
  14.     //departments fetch failed
  15.   }
  16. }
  17.  
  18. void fetchDepartments(){
  19.   ZohodeskPortalApikit.getDepartments(DepartmentsDownloader());//call this method to fetch departments
  20. }

To fetch the layout for a specific Department:

The layout ID helps identify different form structures available under a department. The getLayouts() method retrieves all layouts associated with a given Department ID.

  1. Takes the Department ID as input.
  2. Returns a list of ZDLayout objects containing layout details (e.g., layout ID, name).
  3. It helps determine which layout to apply when configuring ticket fields.
  1. import 'package:zohodesk_portal_apikit/common/ZDResponseCallback.dart';
  2. import 'package:zohodesk_portal_apikit/model/ZDLayout.dart';
  3. import 'package:zohodesk_portal_apikit/zohodesk_portal_apikit.dart'
  4.     show ZohodeskPortalApikit;
  5.  
  6. class LayoutsDownloader implements LayoutsCallback{
  7.  
  8.   @override
  9.   onError(String errorMessage) {
  10.     //Failed to fetch the layouts
  11.   }
  12.  
  13.   @override
  14.   onLayoutsFetch(List<ZDLayout> layouts) {
  15.     //Layouts fetched Successfully
  16.   }
  17.  
  18. }
  19.  
  20. void fetchLayouts() {
  21.   ZohodeskPortalApikit.getLayouts("departmentId", LayoutsDownloader()); //Call this method to fetch the layouts
  22. }

To fetch the Ticket form fields for a Department and a Layout:

The getTicketForm() method retrieves the ticket form structure, including all sections and fields, for a specified Department ID and Layout ID.

  1. Takes the Department ID and Layout ID as inputs.
  2. Returns a ZDTicketForm object containing all ticket sections and fields.
  3. Helps in configuring ticket fields, ensuring mandatory fields are included, and managing form visibility.
  1. import 'dart:collection';
  2. import 'package:zohodesk_portal_apikit/model/ZDTicketForm.dart';
  3. import 'package:zohodesk_portal_apikit/zohodesk_portal_apikit.dart' show ZohodeskPortalApikit;
  4. import 'package:zohodesk_portal_apikit/common/ZDResponseCallback.dart' show TicketFormCallback;
  5.  
  6. class FormCallback implements TicketFormCallback{
  7.   @override
  8.   onError(String errorMessage) {
  9.     //Failed to Fetch the Ticket Fields
  10.   }
  11.  
  12.   @override
  13.   onTicketFormDownloaded(ZDTicketForm ticketForm) {
  14.     //Successfully fetched the Ticket Fields
  15.   }
  16. }
  17.  
  18. void fetchTicketForm(){
  19.   HashMap<String, String>  map = HashMap();
  20.   map["departmentId"] = "pass departmentId here";
  21.   map["layoutId"] = "pass layoutId here";
  22.   ZohodeskPortalApikit.getTicketForm(FormCallback(), map, null);
  23. }

To fetch Ticket fields for a Layout:

The getTicketFields() method retrieves all available ticket fields for a given Department ID and Layout ID. This enables developers to dynamically access field details, including API names, data types, and validation rules.

  1. Requires Department ID and Layout ID as inputs.
  2. Returns a ZDTicketFieldsList containing all ticket fields.
  3. Used to retrieve field metadata, which is essential for pre-filling or displaying ticket fields dynamically.
  1. import 'dart:collection';
  2. import 'package:zohodesk_portal_apikit/zohodesk_portal_apikit.dart' show ZohodeskPortalApikit;
  3. import 'package:zohodesk_portal_apikit/common/ZDResponseCallback.dart' show TicketFieldsCallback;
  4. import 'package:zohodesk_portal_apikit/model/ZDTicketFieldsList.dart' show ZDTicketFieldsList;
  5.  
  6. class FieldsCallback implements TicketFieldsCallback{
  7.   @override
  8.   onTicketFieldsDownloaded(ZDTicketFieldsList ticketFields){
  9.     //Successfully fetched the Ticket Fields
  10.   }
  11.   @override
  12.   onError(String errorMessage) {
  13.     print(errorMessage);
  14.     //Failed to Fetch the Ticket Fields
  15.   }
  16. }
  17.  
  18. void fetchTicketFields(){
  19.   HashMap<String, String>  map = HashMap();
  20.   map["departmentId"] = "pass departmentId here";
  21.   map["layoutId"] = "pass layoutId here";
  22.   ZohodeskPortalApikit.getTicketFields(FieldsCallback(), map, null);
  23. }