Skip to main content

KI-157

Account Search throws "Aggregate query" error when restricted to the selected institution​

Created date08/19/2026Updated date10/02/2026
StatusDoneRelated work itemMSS-109, MIC-4883
DescriptionA person search in Account Search can fail with one of the following errors when Restrict to Selected Institution is selected and a term is typed in the free-text Search box:

- Aggregate query has too many rows for direct assignment, use FOR loop
- System.LimitException: Too many query rows: 50001



For institutions with fewer affiliated accounts, the search doesn't fail. Instead, it returns unrelated people affiliated with the institution instead of the person searched for.

This is a different issue from KI-131, which remains fixed in V16. Searches that leave the free-text Search box empty and use only field filters, such as Last Name, aren't affected.
Root CauseWhen the restriction was selected, Account Search discarded the accounts that matched the search term. Instead, it evaluated every account affiliated with the selected institution, along with each account's Contact Information and Affiliation records. For institutions with many affiliated accounts, this exceeds Salesforce query limits. Both error messages come from the same problem, reached at different data volumes.
Affects version(s)V16, V17, V18Impacted capabilitiesInquiry Management
Steps to reproduce
  1. Open or create an Interaction.
  2. In Account Search, search for an institution with many affiliated accounts, and add it to the Interaction.
  3. Switch to a person search.
  4. Select Restrict to Selected Institution.
  5. Type a person's name in the free-text Search box and search. An error appears, or unrelated affiliated people are returned instead of the matching person.
WorkaroundUse either of these workarounds:
  • With Restrict to Selected Institution selected, leave the free-text Search box empty and search using the field filters, such as Last Name and First Name.
  • Clear Restrict to Selected Institution and search for the person without it.
Fix versionV19Resolution notesA restricted search now returns only accounts that match the search term and are affiliated with the selected institution. For Restrict to Selected Requester, it returns only matches affiliated with the selected requester. The search also completes for large institutions without hitting Salesforce query limits. For details, see the Fall '26 (V19) Release Notes.