---
title: Retrieve agency offices
summary: Load one office or a scoped office collection from AGENT.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-31
library: SAIF.Business.Policy.Agency
reference_type: package
operation_id: OP-008
trigger: A caller requests one office or all offices for an agency.
---

# Retrieve agency offices

This operation retrieves office rows from `AGENT` by reusing a predicate that limits results to non-LOV-excluded office or agency-location rows.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-008 |
| **Trigger** | A caller invokes `clsAgencyOffice.GetAgencyOffice` or `clsAgencyOfficeCollection.GetAgencyOfficeCollection`. |
| **Inputs** | `IDataPortalInfo`, office number and/or agency sequence number |
| **Outputs** | `clsAgencyOffice` or `clsAgencyOfficeCollection` |
| **Primary components** | `clsAgencyOffice`, `clsAgencyOfficeCollection`, shared office SQL constant |
| **Entry point** | `Business\SAIF.Business.Policy.Agency\clsAgencyOffice.vb`, `Business\SAIF.Business.Policy.Agency\clsAgencyOfficeCollection.vb` |

## Steps
1. Build either a single-object criteria keyed by office number or a collection criteria keyed by agency sequence number.
2. Pass the criteria through the BOF data portal retrieve lifecycle ([BR-024](../business-rules.md#br-024-the-library-is-retrieve-only)).
3. Apply the office-only `AGENT` predicate so only non-LOV-excluded agency or location rows qualify ([BR-015](../business-rules.md#br-015-agency-office-retrieval-requires-non-lov-excluded-office-rows)).
4. Execute [SQL-005](../sql/SQL-005-retrieve-agency-office-by-agent-number.md) for the keyed path or [SQL-006](../sql/SQL-006-retrieve-agency-offices-for-an-agency.md) for the collection path against [AGENT](../database-tables.md#agent).
5. Hydrate one office or many offices from the returned reader; missing keyed rows remain default-initialized ([BR-001](../business-rules.md#br-001-missing-key-retrieval-returns-a-default-object)).
6. Expose the loaded offices to active and aggregation helpers ([BR-016](../business-rules.md#br-016-agency-office-number-is-required), [BR-025](../business-rules.md#br-025-identity-keys-are-agency-seq-contract-seq-and-agent-number)).

## Process flow

The following diagram visualizes the office retrieve paths.

```mermaid
flowchart TD
  Start([Office request]) --> Type{Single or collection?}
  Type -->|Single| One[Run SQL-005]
  Type -->|Collection| Many[Run SQL-006]
  One --> FillOne[Fill clsAgencyOffice]
  Many --> FillMany[Load office collection]
  FillOne --> End([Offices returned])
  FillMany --> End
```

## Failure and edge-case behavior
- Missing keyed rows return a default-initialized office object.
- Only rows matching the office/location predicate are ever returned from `AGENT`.

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Database tables](../database-tables.md)
- [SQL catalog](../sql/index.md)
- [API reference](../api/index.md)

## Sources
- `Business\SAIF.Business.Policy.Agency\clsAgencyOffice.vb`
- `Business\SAIF.Business.Policy.Agency\clsAgencyOfficeCollection.vb`
