You need to sign in to do that
Don't have an account?
Luvara
Null object in aggregate result
I am trying to display an aggregate result of various metrics in visualforce pages. The result displays fine in the pages, but I am getting the error "Attempt to de-reference a null object" when I run the tests.
public decimal getCaseSLA (){ AggregateResult agg2 = [Select AVG(SLA_Response_Time__c) sla from Case WHERE CreatedDate = LAST_N_DAYS:30 ]; decimal cs3 = (decimal)agg2.get('sla'); return cs3.setscale(2); }
I've tried a few iterations with no luck. Help would be appreciated.
Thanks,
Chris
What's the test code?
It seems like either you have to add some test data so it's guaranteed to be not null.
Or you can amend you method with an if
I was adding in my own test data, but as soon as cleared that out, and went with the following, it's now working. Always something simple...