Prevent accidental clearing of default ticket status
Enhanced save logic to protect against losing the default ticket status value when saving settings with an empty dropdown: - Only update to new value if a status is actually selected - Only allow clearing if reference data is loaded (dropdown has options) - Preserve existing value if dropdown is empty (no reference data) This fixes the issue where saving settings before reference data loaded would overwrite the previously configured default status with NULL, causing "Create Autotask ticket" to fail with error about missing default status. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a2895b6409
commit
17b64d1f66
@ -482,7 +482,15 @@ def settings():
|
|||||||
|
|
||||||
if "autotask_default_ticket_status" in request.form:
|
if "autotask_default_ticket_status" in request.form:
|
||||||
try:
|
try:
|
||||||
settings.autotask_default_ticket_status = int(request.form.get("autotask_default_ticket_status") or 0) or None
|
form_value = request.form.get("autotask_default_ticket_status", "").strip()
|
||||||
|
if form_value: # Only update if a value was actually selected
|
||||||
|
settings.autotask_default_ticket_status = int(form_value)
|
||||||
|
elif form_value == "" and settings.autotask_default_ticket_status is not None:
|
||||||
|
# If explicitly cleared (empty string submitted) and was previously set,
|
||||||
|
# allow clearing only if reference data is loaded (dropdown has options)
|
||||||
|
if getattr(settings, "autotask_cached_ticket_statuses_json", None):
|
||||||
|
settings.autotask_default_ticket_status = None
|
||||||
|
# Otherwise: keep existing value (prevents accidental clearing when dropdown is empty)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user