# WRLC Retention

Processes a user-uploaded CSV of barcodes to bulk add or remove WRLC retention commitments across institutions, then emails a summary of results.

#### At a glance

- **Status:** Active
- **Applies consortium-wide?:** Yes — processes barcodes across multiple Alma Institution Zones via subworkflows
- **Runs on:** Alma Institution Zones (via Network routing in subworkflows)
- **Trigger:** Manual form submission with CSV upload
- **Primary outcome:** Bulk adds or removes WRLC retention flags on item records.
- **Who receives results:** The email address provided in the form submission.

---

#### Why this exists

WRLC retention commitments must be applied or removed at scale when retention decisions change. Performing this manually in Alma would require record-by-record updates across multiple institutions.

This workflow enables controlled bulk processing by:

- Accepting a structured CSV upload
- Confirming the number of records before execution
- Calling standardized subworkflows for each barcode
- Emailing a clear results summary

It centralizes retention management while preserving audit visibility.

---

#### What it does

- Presents a web form allowing staff to:
    
    
    - Choose **Add WRLC Retention** or **Remove WRLC Retention**
    - Upload a CSV file (maximum 4,000 barcodes)
    - Provide an email address for results
- Counts rows in the uploaded file.
- Displays a confirmation screen showing:
    
    
    - Number of barcodes detected
    - Whether retention will be added or removed
- After confirmation:
    
    
    - Processes each row individually.
    - Calls the appropriate subworkflow:
        
        
        - [**Subworkflow – Add WRLC Retention**](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-add-wrlc-retention)
        - [**Subworkflow – Remove WRLC Retention**](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-remove-wrlc-retention)
- Aggregates results (successes and errors).
- Sends a formatted summary email.

---

#### Where it runs

- **Alma IZ(s):**
    
    
    - Dynamically determined per row using the “Institution Code” column in the CSV.
- **Systems touched:**
    
    
    - Alma APIs (via subworkflows)
    - Email (sent from `reports@wrlc.org`)
- **Reports / queries used:** None

---

#### How it works

##### Logic overview

1\. Form Submission

The workflow begins with a form requiring:

- Dropdown selection:
    
    
    - Add WRLC Retention
    - Remove WRLC Retention
- CSV upload (must contain ≤ 4,000 rows)
- Email address

Required CSV format:

<div class="group TyagGW_tableWrapper flex flex-col-reverse w-fit" id="bkmrk-barcode-institution-" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="2485" data-start="2423"><thead data-end="2453" data-start="2423"><tr data-end="2453" data-start="2423"><th class="" data-col-size="sm" data-end="2433" data-start="2423">Barcode</th><th class="" data-col-size="sm" data-end="2453" data-start="2433">Institution Code</th></tr></thead></table>

</div>⚠️ The workflow does **not validate header names**; it assumes:

- First row is header.
- First column = Barcode.
- Second column = Institution Code.

---

2\. Row Counting &amp; Review Step

Before processing:

- The uploaded file is decoded from base64.
- Blank lines are removed.
- Header row is subtracted from count.
- A confirmation screen displays:
    
    
    - Number of barcodes detected.
    - Whether retention will be added or removed.

This confirmation step prevents accidental bulk updates.

---

3\. Branch Based on User Selection

An **If** node evaluates the dropdown choice:

- If **Add WRLC Retention** → calls:
    
    
    - `Subworkflow – Add WRLC Retention`
- Otherwise → calls:
    
    
    - `Subworkflow – Remove WRLC Retention`

Each CSV row triggers one subworkflow execution (`mode: each`).

⚠️ Errors are set to `continueRegularOutput`, meaning:

- Processing continues even if some rows fail.
- Failures are captured and summarized later.

---

4\. Subworkflow Processing

Each row:

- Routes to the correct Institution Zone.
- Retrieves the item by barcode.
- Adds or removes WRLC retention fields.
- Returns success or error information.

(Full logic documented in the respective subworkflow entries, [Add WRLC Retention](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-add-wrlc-retention) and [Remove WRLC Retention](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-remove-wrlc-retention))

---

5\. Aggregate Results

After all rows are processed:

The **Summarize results** node:

- Counts total processed rows.
- Counts successful updates.
- Collects error details.
- Attempts multiple barcode fallbacks:
    
    
    - `_inputBarcode`
    - `item_data.barcode`
    - `Barcode`

Errors are retained even if barcode is missing.

---

6\. Email Results

Sends an HTML-formatted email containing:

- Total processed
- Successful updates
- Error count
- Detailed error list (if any)

From address: `reports@wrlc.org`  
Recipient: Email provided in form

---

##### If results exist

- Each barcode is processed independently.
- Successful updates are counted.
- Errors are listed individually.
- User receives detailed summary email.

##### If no results

- If file contains zero data rows:
    
    
    - Processing completes immediately.
    - Email reflects zero processed.
- If all rows fail:
    
    
    - Email lists all errors.
- Workflow does not halt due to individual row failures.

---

#### Artifacts produced

- Updated Alma item records (via subworkflows).
- Summary email to submitting user.
- No files, sets, or spreadsheets are created.