---
title: Retrieve affiliated policies
summary: Retrieves the affiliated policies for one affiliation family, filtered to the requesting agent.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-31
library: SAIF.Business.View.Policy
reference_type: package
operation_id: OP-08
trigger: A caller requests the affiliated policy collection for a policy
---

# Retrieve affiliated policies

Where the association list describes how policies are linked, this operation produces the display list an application actually shows: the policies affiliated with a given policy under one affiliation family, optionally with a totals row, and optionally narrowed to the agent or agency making the request.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-08 |
| **Trigger** | A caller requests the affiliated policy collection for a policy |
| **Inputs** | `IDataPortalInfo`, policy number, affiliate type, totals flag, and optional agent or agency filters |
| **Outputs** | A populated `clsAffiliatedPolicyCollection` with the source policy marked current |
| **Primary components** | `clsAffiliatedPolicyCollection.GetAffiliatedPolicyCollection` |
| **Entry point** | `Business/SAIF.Business.View.Policy/clsAffiliatedPolicyCollection.vb` |

## Steps

1. In `BeforeRetrieve`, set the statement to `pk72846_view_policy.getpolicyaffiliatelist` and add the policy number, the upper-cased affiliate type, the totals flag, and the result cursor ([SQL-001](../sql/SQL-001-affiliated-policy-list.md)).
   - The affiliate type is truncated to twenty-five characters and its prefix selects which relationship family the procedure walks.
   - The totals flag is passed as the literal text `TRUE` or `FALSE`.
2. In `AfterRetrieve`, load each returned row into a `clsAffiliatedPolicy`.
3. Apply the agent and agency filter as rows are added ([BR-020](../business-rules.md#br-020-affiliated-policies-are-filtered-to-the-requesting-agent-or-agency-when-specified)).
   - If both the criteria agent number and agency sequence number are zero, keep every row.
   - Otherwise keep a row only when its agent number or agency sequence number matches the criteria.
4. Mark the source policy as the current item in the collection so that callers can distinguish it from its affiliates.
5. Whether the resulting collection should be shown at all is a separate decision that depends on the caller's access level and the policy's affiliate type ([BR-011](../business-rules.md#br-011-affiliated-policy-visibility-depends-on-user-access-level-and-affiliate-type)).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
    Start([Affiliated policies requested]) --> Q[BeforeRetrieve adds policy number,<br>affiliate type and totals flag]
    Q --> X[(pk72846_view_policy.getpolicyaffiliatelist)]
    X --> L[Load each row into<br>clsAffiliatedPolicy]
    L --> F{Agent or agency<br>filter supplied?}
    F -->|No| Keep[Keep every row]
    F -->|Yes| Match{Row matches the<br>agent or agency?}
    Match -->|Yes| Keep
    Match -->|No| Skip[Skip the row]
    Keep --> Cur[Mark the source policy current]
    Skip --> Cur
    Cur --> Ok([Affiliated policy collection])
```

## Failure and edge-case behavior

- An affiliate type with no matching prefix yields an empty collection rather than an error.*
- Filtering happens after retrieval, so rows the caller may not see are still transferred from the database.

> **Note:** Statements marked with `†` are derived from dependency library
> documentation via the Legends CLI. Statements marked with `*` were inferred
> from code structure or contextual evidence. Statements marked with `**` could
> not be confirmed; treat as unknown until verified.

## Related documentation

- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)
- [Procedures](../procedures/index.md)
- [Security and authorization](../security-authorization.md)
- [API reference](../api/index.md)

## Sources

- `Business/SAIF.Business.View.Policy/clsAffiliatedPolicyCollection.vb`
- `Business/SAIF.Business.View.Policy/clsAffiliatedPolicy.vb`
