SearchKit - Fix undefined variable for searches of Afforms and other non-DAO entities
authorColeman Watts <coleman@civicrm.org>
Mon, 6 Dec 2021 03:18:07 +0000 (22:18 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 6 Dec 2021 03:18:07 +0000 (22:18 -0500)
ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js

index d0b8750bc3e31ea174a06b769d7b305f56b23556..f94bd17440e0a39a5d6991b14c4016aa243624fc 100644 (file)
       // Is a column eligible to use an aggregate function?
       this.canAggregate = function(col) {
         // If the query does not use grouping, never
-        if (!ctrl.savedSearch.api_params.groupBy.length) {
+        if (!ctrl.savedSearch.api_params.groupBy || !ctrl.savedSearch.api_params.groupBy.length) {
           return false;
         }
         var arg = _.findWhere(searchMeta.parseExpr(col).args, {type: 'field'}) || {};