# Reassign Retention in batch

Reassigns WRLC Retention commitments in batches using an uploaded spreadsheet of item barcodes and institution codes. Staff receive an email with a spreadsheet showing the outcome for each item returned by the process.

#### At a glance

- **Status:** Active
- **Environment / Tags:** Network Zone; Live
- **Applies consortium-wide?:** Yes
- **Runs on:** Alma Institution Zones identified by the submitted institution codes, using consortial lookup and retention reassignment subworkflows.
- **Trigger:** Manual submission through an Alma-authenticated form; no scheduled trigger.
- **Primary outcome:** Attempts to reassign WRLC Retention commitments for submitted items and reports the results.
- **Who receives results:** The email address entered on the submission form.

#### Why this exists

WRLC HQ may need to reassign retention commitments for multiple items at once. This workflow provides a batch submission process, separates WRLC Retention items from items that cannot be reassigned automatically, and returns a report so staff can identify successful reassignments and items requiring further attention.

#### What it does

- Accepts a required Excel (`.xlsx`) spreadsheet and email address through a form. The spreadsheet must use the exact column headings **Barcode** and **Institution Code**, with institution codes such as `01WRLC_AMU` or `01WRLC_GWA`.
- Instructs staff to submit **250 barcodes or fewer** at a time. The form also identifies multivolume items, items without a Network Zone bibliographic link, and WRLC Permanent items as ineligible for this batch process.
- Reads the spreadsheet and maps **Barcode** to `barcode` and **Institution Code** to `owner_of_item_code`.
- Calls [**Subworkflow - Look up consortial item by barcode**](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-look-up-consortial-item-by-barcode) separately for each submitted row.
- Routes items whose returned retention reason exactly equals **WRLC Retention** to [**Subworkflow - Reassign WRLC Retention**](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-reassign-wrlc-retention).
- Skips automatic reassignment for **WRLC Permanent** items and records: “Item doesn't meet criteria for batch reassignment; the item has WRLC Permanent status”.
- Routes all other returned retention-reason values to a status of: “This item is not marked for Retention”.
- Combines the returned outcomes and retains the `barcode` and `reassign_retention_status` fields for reporting.
- Creates an Excel results file and emails it to the submitting staff member.

#### Where it runs

- **Alma IZ(s):** Determined by the submitted institution codes and the called subworkflows.
- **Systems touched:** LibOW ; Gmail for results delivery.
- **Reports / queries used:** No Alma Analytics report or query is configured in this workflow. Item lookup and reassignment are delegated to: 
    - [**Subworkflow - Look up consortial item by barcode**](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-look-up-consortial-item-by-barcode)
    - [**Subworkflow - Reassign WRLC Retention**](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-reassign-wrlc-retention)
- **Email credential label:** Gmail Credentials - Generic LibOW.

#### How it works

##### Logic overview

The workflow reads each spreadsheet row, looks up the item, and checks its returned retention reason. Only **WRLC Retention** items proceed to the reassignment subworkflow. WRLC Permanent items and other returned values receive explanatory statuses without entering that reassignment step.

The results email lists these possible outcomes:

- Retention reassigned to another item, identified by barcode.
- Item is the last available retention monograph in the consortium.
- Item has WRLC Permanent status.
- Item is not marked either Retention or Permanent.
- Item is not linked to the Network Zone.
- Item is not a single-part monograph.
- An error message from Alma.

##### If results exist

Returned items follow the appropriate retention-status branch. The workflow combines their outcomes into an Excel spreadsheet and emails it with the subject **Retention Reassignment Items**.

##### If no results

If the lookup returns a record without a matching retention reason, it follows the fallback branch and receives the “not marked either Retention or Permanent” status.

##### Artifacts produced

- An Excel results file with the configured filename pattern **`reassign-retention-YYYY-MM-DD,`**containing two report columns: **`barcode`** and **`reassign_retention_status`**.
- An email sent to the address entered on the form, with the results file attached and the sender name **Washington Research Library Consortium**.