Field Dependencies
Field Dependencies allow you to create parent-child relationships between fields while users create new tickets. This helps display only the relevant options based on previous selections, making ticket forms cleaner, faster to complete, and less prone to errors.
For example, selecting a Category can automatically filter the available Sub-category options, or choosing an application can display only the issues related to that application.
Supported Field Types
Field Dependencies currently support only Select and Link field types and are available only while creating new tickets.
Add Custom Fields
Before creating field dependencies, add the required custom fields to the ticket creation form.
- Open Desk and navigate to the HD Ticket DocType.
- Use Customize Form to create the required custom field.
- Copy the field name.
- Open the HD Ticket Template document named Default.
- Add the field name to the Fields table.
- Optionally enable Hide from Customer if the field should only be visible to agents.
Create Field Dependencies
Once the required fields are added to the ticket template, dependencies can be configured in two ways:
- Using the Field Dependencies interface.
- Using HD Form Scripts for advanced logic.
Method 1: Using the Field Dependencies Interface
This method lets you configure dependencies without writing any code.
- Open Settings from the user menu.
- Navigate to the Field Dependencies tab.
- Click New.
- Select the Parent Field and Child Field.
- Map each parent field value to the child values that should be available.
Important
Both the parent and child fields must already exist in the Default HD Ticket Template. A child field can only belong to one dependency configuration.
Control Child Field Visibility
You can control when the child field becomes visible.
- Disabled — The child field is always visible.
- Any — The child field becomes visible as soon as the parent field has any value.
- Specific Values — Show the child field only when selected parent values match.
Control Mandatory Fields
You can also make the child field required only for specific parent field values.
- Disabled — The child field is optional.
- Any — Required whenever the parent field contains a value.
- Specific Values — Required only for selected parent values.
Example
If Category is set to Billing, Accounting, or Payroll, the Sub Category field can be displayed and made mandatory while remaining optional for other categories.
Method 2: Using HD Form Scripts
For more advanced behavior, you can dynamically filter field options using an HD Form Script.
- Open Desk.
- Navigate to HD Form Script.
- Select HD Ticket as the DocType.
- Choose Form as the script type.
- Enable Enabled and Apply on New Page.
- Create
onChangehandlers to update field options dynamically.
Using applyFilters()
The applyFilters() function updates the available options of a Select or Link field during ticket creation.
It accepts two parameters:
- Field Name — The field whose options should change.
- Options — An array of allowed values. Passing
nullrestores the default options.
For example, selecting ERPNext as an application can display only ERPNext-related categories, while selecting HRMS displays HRMS-specific options.
Additional Customizations
Field dependencies work well alongside standard Frappe field expressions.
- display_depends_on — Show or hide fields using conditional expressions.
- mandatory_depends_on — Make fields mandatory only when specified conditions are satisfied.
Best Practices
- Keep dependency chains simple to improve usability.
- Add custom fields to the HD Ticket Template before creating dependencies.
- Use the visual Field Dependencies interface whenever possible.
- Use HD Form Scripts only when dynamic or complex filtering logic is required.
- Test ticket creation after updating dependencies to ensure all field combinations behave as expected.