Вот как в функции вернуть не undefined ? :)
proc: function(Id)
{
  return getCallCountForButtonCaption(Id);
Вот как сделать чтобы возвращать не undefined, а результат асинхронного вызова который
аяксом вернется из getCallCountForButtonCaption т. е. синхронизировать асинхронный вызов
}
            getCallCountForButtonCaption: function (candId) {
                this.logStep('getCallCountForButtonCaption started...');
                // Создаем экземпляр класса Terrasoft.EntitySchemaQuery с корневой схемой [Contact].
                
                var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
                    rootSchemaName: "AACandCall"
                });
                // Добавляем колонку с именем основного контакта контрагента, который относится к данному контакту.
                esq.addColumn("CallCount");
                esq.filters.add("filterByIdCand",
                    esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,
                        "IdCand", candId));
                esq.getEntityCollection(function (response) {
                       this.logStep('ForButtonCaption callCount request has started!');
                    if (response.success) {
                        this.logStep('ForButtonCaption callCount response.success is true');
                        if (response.collection.getCount() > 0) {
                            var firstItem = response.collection.getByIndex(0);
                            var callCount = firstItem.values.CallCount;
                            //this.setButtonCaption(callCount);
                            return callCount;
                        }
                        else {
                            this.logStep('ForButtonCaption response.collection.getCount() is ZERO');
                            return -1;
                        }
                        return -1;
                    }
                    else {
                        this.logStep('ForButtonCaption callCount response.success is false');
                        return -1;
                    }
                }, this);
                this.logStep('getCallCount finished...');
            },