# Remove Duplicate Retention Items

This workflow identifies duplicate WRLC Retention commitments that can occur after bibliographic records are merged and preserves a single Retention commitment for each title. It automatically removes the duplicate commitments (including corresponding SCF copies when applicable) and emails a summary of the results.

#### At a glance

- **Status:** Active
- **Environment / Tags:** Network Zone; Live; Analytics
- **Applies consortium-wide?:** Yes
- **Runs on:** WRLC Alma Network Zone, with updates made to affected Institution Zone and Shared Collections Facility items
- **Trigger:** Started manually through a LibOW form
- **Primary outcome:** Identifies duplicate WRLC Retention commitments created after bibliographic records are merged, preserves one commitment per Network Zone record, and removes the duplicates.
- **Who receives results:** The staff member who submits the form receives an email at the address they provide.

#### Why this exists

When bibliographic records are merged, items from multiple records may become associated with the same Network Zone record. This can result in more than one item carrying a WRLC Retention commitment for the same title.

This workflow helps maintain the consortium’s retention data by preserving one Retention commitment for each Network Zone record and removing the additional commitments. When an affected item has a corresponding copy in the Shared Collections Facility, the workflow also removes the Retention commitment from that SCF copy.

#### What it does

- A staff member submits a Network Zone set ID and an email address through the workflow form. 
    - The submitted set should contain the bibliographic records that need to be reviewed. The form recommends using a set of recently merged records to reduce processing time.
- The workflow retrieves every member of the supplied Network Zone set.
- For each bibliographic record, it runs an Alma Analytics report to retrieve items for monographs carrying WRLC Retention commitments.
- The workflow determines whether more than one Retention item is associated with the same Network Zone record.
- When duplicates are found, the workflow groups the items by Network ID and selects one Retention commitment to preserve. An SCF copy is given preference when the retained item is selected.
- The remaining Retention commitments are sent to the [**Subworkflow – Remove WRLC Retention**](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/subworkflow-remove-wrlc-retention) workflow for removal.
- When an item is stored remotely, the workflow also sends the corresponding SCF barcode—created by adding `X` to the owning institution’s barcode—to the removal subworkflow.
- After processing, the workflow emails the submitter either a spreadsheet showing the outcome for each item or a message confirming that no duplicates were found.

#### Where it runs

- **Alma IZ(s):**
    - WRLC Network Zone
    - Affected member Institution Zones
    - WRLC Shared Collections Facility IZ, when a corresponding SCF copy exists
- **Systems touched:**  
    
    - Alma Analytics
    - Gmail
- **Reports / queries used:**
    - **Analytics folder:** `/shared/Washington Research Library Consortium (WRLC) Network/Reports/Retention Reassignment`
        - **Analytics report:** `Duplicate Retention Analysis`
            - The report is filtered by the Network ID of each bibliographic record in the submitted set.
            - In the report, the results are also filtered by the following criteria: 
                - Lifecycle = Active
                - Committed to Retain = Yes
                - Retention Reason = WRLC Retention
                - Description is null
- **Referenced credential labels:**
    - `NZ Production - Alma APIs - Read & Write`
    - `Gmail Credentials - Generic LibOW`

#### How it works

##### Logic overview

- **If results exist:**  
    The workflow groups Retention items by Network ID, preserves one item for each record, and removes the Retention commitment from the remaining items. When applicable, it also removes the commitment from corresponding SCF copies. The results are combined into an Excel spreadsheet and emailed to the submitter.
- **If no results exist:**  
    The workflow makes no changes and emails the submitter to confirm that no bibliographic records with duplicate WRLC Retention items were found in the supplied set.
- **If the workflow encounters an error:**  
    Execution is passed to the configured LibOW error workflow.

##### Artifacts produced

When duplicate Retention commitments are found, the workflow produces an Excel spreadsheet containing item information and a **Status** column. Status values include:

- `Retention preserved`
- `Retention removed`

The spreadsheet may include:

- Network ID
- Institution code
- Barcode
- Permanent and temporary location information
- Remote-storage status
- Retention processing status

The workflow export does not define a specific filename for the spreadsheet.