From 49ae55029d08de2f9ba6102d765acbe35b999cb4 Mon Sep 17 00:00:00 2001
From: aydreeihn <adriane@enhancesoft.com>
Date: Wed, 27 Jun 2018 13:09:05 -0500
Subject: [PATCH] Issue: New Task Department Sorting

This commit fixes an issue where Departments were not in alphabetical order when opening a new Task. This will also ensure that Departments will be alphabetically sorted anywhere that contains a DepartmentField.
---
 include/class.forms.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/class.forms.php b/include/class.forms.php
index 6e3e39141..6452059a8 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -2719,7 +2719,8 @@ class DepartmentField extends ChoiceField {
 
         $active_depts = Dept::objects()
           ->filter(array('flags__hasbit' => Dept::FLAG_ACTIVE))
-          ->values('id', 'name');
+          ->values('id', 'name')
+          ->order_by('name');
 
         $choices = array();
         if ($depts = Dept::getDepartments(null, true, Dept::DISPLAY_DISABLED)) {
-- 
GitLab