Skip to content

Retrieve affiliated policies (legacy)

Loads the legacy affiliate-policy list for a policy — the predecessor to the newer Associations/PolicyAssociationList mechanism (see Retrieve policy associations) — filtering results by agent/agency number and marking the source policy as "current" in the resulting collection.

Field Value
Operation ID op-09-retrieve-affiliated-policies
Trigger Consumer reads obsolete affiliate members (clsAffiliatedPolicyCollection.GetAffiliatedPolicyCollection)
Inputs Policy number, clsPolicyData.AffiliateTypes, optional agent number / agency sequence number
Outputs clsAffiliatedPolicyCollection
Primary components clsAffiliatedPolicyCollection.GetAffiliatedPolicyCollection, BeforeRetrieve/AfterRetrieve, SetCurrent
Entry point SAIF.Business.View.Policy/clsAffiliatedPolicyCollection.vb

Steps

  1. Caller invokes GetAffiliatedPolicyCollection(inDataportal, inPolicyNum, inAffiliateType), which builds a Criteria and forwards to the Criteria-accepting overload (BR-VP-011).
  2. The Criteria-accepting overload branches on inCriteria.AffiliateType: if it is NonAffiliated, the data-access layer's CreateObject is called instead of RetrieveObject, producing a new, empty collection without querying the database at all (BR-VP-013); otherwise RetrieveObject proceeds normally.
  3. Framework invokes BeforeRetrieve: assigns MyCriteria.RetrieveSQL, sets CommandType = StoredProcedure, and binds in_policy_num, in_affiliate_type (the affiliate type name, upper-cased, SQL-014), and in_include_affil_totals ("TRUE"/"FALSE" string literal derived from MyCriteria.IncludeAffiliateTotals), plus a cursor parameter recordset (SQL-001, procedure pk72846_view_policy.getpolicyaffiliatelist).
  4. Framework executes the request against Oracle.
  5. Framework invokes AfterRetrieve: loops Reader.Read, constructs a New clsAffiliatedPolicy and calls AffiliatedPolicy.Load(MyCriteria.DataPortalInfo, Reader) per row, then applies an agent/agency filter before adding each row to the collection (BR-VP-012):
  6. If MyCriteria.AgentNum = 0 And MyCriteria.AgencySeqNum = 0, the row is always added (no filter).
  7. Else if MyCriteria.AgentNum <> 0 and matches AffiliatedPolicy.AgentNum, the row is added.
  8. Else if MyCriteria.AgencySeqNum <> 0 and matches AffiliatedPolicy.AgencySeqNum, the row is added.
  9. Rows matching none of these are silently excluded.
  10. After the loop, SetCurrent(MyCriteria.PolicyNum.ToString) marks the source policy's row as the collection's current item (commented-out code shows an earlier version that instead defaulted to item 0 when the source policy was not found in the result set).
  11. clsPolicyData.SetCurrentAffiliatedPolicy(inPolicyNum) (in clsPolicyData.vb, #Region "Policy Affiliate") provides an alternate entry point that operates on an already-retrieved collection rather than re-querying.*

Process flow

flowchart TD
    Start(["Consumer requests<br>affiliated policies"]) --> A{AffiliateType =<br>NonAffiliated?}
    A -->|Yes| B["CreateObject: empty<br>collection, no query"]
    A -->|No| C["RetrieveObject:<br>BeforeRetrieve assigns<br>getpolicyaffiliatelist"]
    C --> D["Framework executes<br>against Oracle"]
    D --> E["AfterRetrieve reads rows"]
    E --> F{More rows?}
    F -->|Yes| G["New clsAffiliatedPolicy / Load"]
    G --> H{Agent/agency<br>filter matches?}
    H -->|Yes| I["Add to collection"]
    H -->|No| F
    I --> F
    F -->|No| J["SetCurrent to source<br>policy number"]
    B --> End(["Return clsAffiliatedPolicyCollection"])
    J --> End

Failure and edge-case behavior

  • When AffiliateType = NonAffiliated, the collection is created empty with no data-access call at all — a caller cannot distinguish "no query needed" from "query returned zero rows" by inspecting the collection alone.*
  • The agent/agency filter in AfterRetrieve silently drops non-matching rows rather than raising or logging — a caller who expected the full unfiltered affiliate list would see a partial result with no indication rows were excluded.*
  • SetCurrent assumes the source policy number is present among the retrieved rows; the currently-active code no longer has the fallback-to-item-0 behavior that the commented-out code shows was once in place, so if the source policy is absent the current-item selection is unclear from this pass alone.**

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Business.View.Policy/clsAffiliatedPolicyCollection.vb
  • SAIF.Business.View.Policy/clsPolicyData.vb