Skip to main content
deleted 1 character in body
Source Link

I have done some more debugging and figured it out. For anyone who stumbles upon this in the future with the same problem - the aggregate query will still return a result, so the list will have size 1, but the result will have value null. So the proper handling of this is:

@AuraEnabled(cacheable=true)
public static String wiredMethod() {
    AggregateResult[] results = [SELECT MAX(Name) max FROM Object__c WHERE Available__c = true];
    if (IntegerString.valueOf(results[0].get('max')) == null) return '';
    else return (String) results[0].get('max');
}

I have done some more debugging and figured it out. For anyone who stumbles upon this in the future with the same problem - the aggregate query will still return a result, so the list will have size 1, but the result will have value null. So the proper handling of this is:

@AuraEnabled(cacheable=true)
public static String wiredMethod() {
    AggregateResult[] results = [SELECT MAX(Name) max FROM Object__c WHERE Available__c = true];
    if (Integer.valueOf(results[0].get('max')) == null) return '';
    else return (String) results[0].get('max');
}

I have done some more debugging and figured it out. For anyone who stumbles upon this in the future with the same problem - the aggregate query will still return a result, so the list will have size 1, but the result will have value null. So the proper handling of this is:

@AuraEnabled(cacheable=true)
public static String wiredMethod() {
    AggregateResult[] results = [SELECT MAX(Name) max FROM Object__c WHERE Available__c = true];
    if (String.valueOf(results[0].get('max')) == null) return '';
    else return (String) results[0].get('max');
}
Source Link

I have done some more debugging and figured it out. For anyone who stumbles upon this in the future with the same problem - the aggregate query will still return a result, so the list will have size 1, but the result will have value null. So the proper handling of this is:

@AuraEnabled(cacheable=true)
public static String wiredMethod() {
    AggregateResult[] results = [SELECT MAX(Name) max FROM Object__c WHERE Available__c = true];
    if (Integer.valueOf(results[0].get('max')) == null) return '';
    else return (String) results[0].get('max');
}