如何在Vtiger中当Ticket Status改为Open时隐藏Ticket solution等字段?
Got it, let's break down how to hide fields like Ticket Solution when the Ticket Status is set to Open in Vtiger. I've got two reliable methods for you—one no-code approach for quick wins, and a custom script option for more control.
This is the easiest way if you just need basic conditional hiding based on the status value.
- Head to your Vtiger backend, go to Settings > Module Management > Tickets > Field Management
- Locate the fields you want to hide (like Ticket Solution) and click the edit icon next to them
- On the field edit page, scroll down to the Dependency section
- Click Add Dependency and configure the trigger:
- Trigger Field:
Ticket Status - Condition:
Equals - Value:
Open
- Trigger Field:
- In the Hide Fields list, check all the fields you want to conceal when status is Open
- Save your changes, then refresh the frontend to test the behavior
Pros: No coding required, intuitive setup. Cons: Limited to simple value-based conditions—won’t work for complex logic like multi-field triggers.
If you need more flexibility (like dynamic field behavior or complex rules), a custom JS script is the way to go.
Create the custom script file
Navigate to your Vtiger installation’smodules/Tickets/resources/directory (adjust the path if your setup is different) and create a new file namedticket_status_field_hider.js.Add the script code
Paste this code into the file (replace thefieldsToHidearray with your actual field IDs):jQuery(document).ready(function() { // Listen for changes to the Ticket Status dropdown jQuery('#ticketstatus').on('change', function() { const currentStatus = jQuery(this).val(); // List of field IDs to hide when status is Open const fieldsToHide = ['ticket_solution', 'your_other_field_id']; if (currentStatus === 'Open') { // Hide each target field by hiding its parent table row fieldsToHide.forEach(fieldId => { jQuery(`#${fieldId}`).closest('tr').hide(); }); } else { // Show fields when status is not Open fieldsToHide.forEach(fieldId => { jQuery(`#${fieldId}`).closest('tr').show(); }); } }); // Trigger the change event on page load to set initial state jQuery('#ticketstatus').trigger('change'); });Note: To get the correct field IDs, use your browser’s developer tools to inspect the field elements in the ticket edit form.
Load the script in the Ticket Edit view
Openmodules/Tickets/views/Edit.phpand add this line somewhere in thepreProcess()method (or wherever scripts are included):$this->JS_LIB->includeJS('modules/Tickets/resources/ticket_status_field_hider.js');Clear Vtiger cache
Go to Settings > System Settings > Clear Cache to ensure the new script loads properly.
Pros: Full control over field behavior, supports complex logic. Cons: Requires basic coding knowledge and attention to Vtiger version compatibility.
内容的提问来源于stack exchange,提问作者John Doe

