---
title: Load a user's favorites
summary: Loads the favorite menu items recorded for one user, or all favorites across all users when no user is supplied.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Business.Menu
reference_type: package
operation_id: OP-MENU-08
trigger: Caller requests `GetMenuFavoritesForUser`
---

# Load a user's favorites

Loads the favorite menu items recorded for one user, or all favorites across all users when no user is supplied.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-MENU-08 |
| **Trigger** | Caller requests `GetMenuFavoritesForUser` |
| **Inputs** | `IDataPortalInfo`, user ID |
| **Outputs** | Populated `clsMenuFavoriteCollection` |
| **Primary components** | `clsMenuFavoriteCollection.GetMenuFavoritesForUser` |
| **Entry point** | `SAIF.Business.Menu/clsMenuFavoriteCollection.vb` |

## Steps

1. Build `Criteria(dpi, userID)`.
2. `BeforeRetrieve`: when `UserID.Trim.Length > 0`, use `RetrieveByUserIDSQL` ([SQL-021](../sql/SQL-021-retrieve-menu-favorites-for-user.md), adds `WHERE MENU_FAVORITE.MENU_USER = :UserID`) and `AddParm("UserID", value, 30)`; otherwise use the unfiltered `RetrieveSQL` ([SQL-020](../sql/SQL-020-retrieve-all-menu-favorites.md)). ([BR-MENU-001](../business-rules.md#br-menu-001-scoped-vs-unfiltered-retrieval); table [MENU_FAVORITE](../database-tables.md#menu_favorite))
3. `AfterRetrieve` loads one `clsMenuFavorite` per row.
   - Note: this retrieval does **not** filter on `ITEM_INACTIVE_DATE`, unlike the favorites branch of the authorized-item query ([BR-MENU-006](../business-rules.md#br-menu-006-inactive-favorites-excluded)), so inactive favorites are included here.*

## Process flow

```mermaid
flowchart TD
    Start([GetMenuFavoritesForUser]) --> Choice{UserID supplied?}
    Choice -->|Yes| ByUser["RetrieveByUserIDSQL: WHERE MENU_USER = :UserID"]
    Choice -->|No| All[RetrieveSQL: unfiltered]
    ByUser --> Load[AfterRetrieve: Load each clsMenuFavorite]
    All --> Load
    Load --> Done([Return populated collection])
```

## Failure and edge-case behavior
- Inactive favorites (`ITEM_INACTIVE_DATE` populated) are still returned by this retrieval, unlike the favorites branch of the authorized-item query.*
- No favorites recorded for the user: an empty collection is returned, not an error.

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

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- SAIF.Business.Menu/clsMenuFavoriteCollection.vb
