A developer runs a GlideAggregate to count the number of incidents per category. The query returns unexpected results: some categories show zero counts but should have incidents. What is the most likely cause?
Trap 1: The developer used addAggregate('COUNT', 'category') instead of…
False. The correct way to count incidents per category is to use addAggregate('COUNT', 'category'), which groups by the 'category' field and counts records in each group. Using addAggregate('COUNT') without a field would count all records without grouping, not per category. Therefore, using the two-argument form is not a mistake; it is the correct approach.
Trap 2: The developer must use addQuery('active', true) to include only…
False. There is no requirement to filter only active incidents. The unexpected zero counts are not related to an added query for active incidents. The issue is likely that the query() method was not called, causing no results to be returned.
Trap 3: The GlideAggregate cannot handle null values in the grouped field.
False. GlideAggregate can handle null values in the grouped field; they are grouped together and counted as a separate group. The unexpected zero counts are not due to null handling but rather due to forgetting to call the query() method.
- A
The developer used addAggregate('COUNT', 'category') instead of addAggregate('COUNT').
Why wrong: False. The correct way to count incidents per category is to use addAggregate('COUNT', 'category'), which groups by the 'category' field and counts records in each group. Using addAggregate('COUNT') without a field would count all records without grouping, not per category. Therefore, using the two-argument form is not a mistake; it is the correct approach.
- B
The developer must use addQuery('active', true) to include only active incidents.
Why wrong: False. There is no requirement to filter only active incidents. The unexpected zero counts are not related to an added query for active incidents. The issue is likely that the query() method was not called, causing no results to be returned.
- C
The developer forgot to call the query() method after grouping.
Without query(), no records are processed.
- D
The GlideAggregate cannot handle null values in the grouped field.
Why wrong: False. GlideAggregate can handle null values in the grouped field; they are grouped together and counted as a separate group. The unexpected zero counts are not due to null handling but rather due to forgetting to call the query() method.