# Subworkflow – Remove WRLC Retention

This subworkflow removes WRLC retention commitments from a specified item by clearing retention-related fields in Alma for a given barcode and institution.

#### At a glance

- **Status:** Inactive ([parent workflows](https://alma-documentation-bookstack.azurewebsites.net/books/library-open-workflows/page/add-or-remove-wrlc-retention) are Active)
- **Applies consortium-wide?:** Yes *(*
- **Runs on:** Alma Institution Zones via Network routing
- **Trigger:** Executed by another workflow (subworkflow only; no independent trigger)
- **Primary outcome:** Clears the item’s retention commitment and reason, and removes a matching NZ 583 field when applicable
- **Who receives results:** No direct output; results are returned to the calling workflow.

---

#### Why this exists

WRLC retention commitments are recorded on Alma items and, for bib records linked to the Network Zone, may also be recorded in a 583 field on the NZ bib. This subworkflow gives parent workflows a consistent way to remove those records when a commitment is withdrawn.

---

#### What it does

- Receives `Barcode` and `Institution Code` from the calling workflow.
- Uses `Institution Code` to route the item lookup and update to the appropriate Alma Institution Zone.
- Retrieves the item by barcode, sets `committed_to_retain` to **No**, and clears `retention_reason`.
- Updates the item in Alma.
- Retrieves the item’s IZ bib and checks whether it is linked to an NZ bib.
- If the bib is NZ linked and `Institution Code` is **not** `01WRLC_SCF`, retrieves the NZ bib and removes a 583 field whose `$x` matches the input barcode. It then updates the NZ bib.

- The subworkflow does **not** clear `retention_note`. It also does not check whether the item currently has a WRLC retention commitment before changing its item fields.

---

#### Where it runs

- **Alma IZ:** Selected dynamically from the input `Institution Code`; the workflow does not run across all network members.
- **Alma NZ:** Updated only when the item’s IZ bib is linked to the NZ and the institution code is not `01WRLC_SCF`.
- **Systems touched:** Alma item and bib APIs, Alma Network routing, and the WRLC Institution Information data table.
- **Reports / queries used:** None

---

#### How it works

##### 1. Input and routing

The **“When Executed by Another Workflow”** trigger passes through the input from the parent workflow. The expected fields are `Barcode` and `Institution Code`. **Alma Network** uses `Institution Code` to select the IZ, and **“Retrieve Item by Barcode”** looks up the item there. Missing or incorrect input may prevent the intended item from being updated.

##### 2. Item update

**“Remove WRLC Retention Code”** changes these fields in the retrieved item JSON:

<table id="bkmrk-item-field-value-wri"><tbody><tr><th>Item field</th><th>Value written</th></tr><tr><td>`item_data.committed_to_retain.value`</td><td>`'false'`</td></tr><tr><td>`item_data.committed_to_retain.desc`</td><td>`No`</td></tr><tr><td>`item_data.retention_reason.value`</td><td>Empty string</td></tr><tr><td>`item_data.retention_reason.desc`</td><td>Empty string</td></tr></tbody></table>

**“Update Item Info”** writes the modified item back to its Alma IZ. The code assumes `committed_to_retain` and `retention_reason` are present in the retrieved item structure.

##### 3. NZ bib update

After the item update, **“Retrieve Bib”** gets the item’s IZ bib. The workflow proceeds to NZ 583 removal only when the bib’s linked record type is `NZ` and `Institution Code` is not `01WRLC_SCF`.

On that path, the workflow looks up the institution in the **WRLC Institution Information** data table, retrieves the linked NZ bib, and uses **“Remove 583 Field”** to match a 583 field by its `$x` barcode. **“Update Bib Record”** writes the resulting bib back to Alma. If no 583 field matches the barcode, the removal step leaves the bib’s 583 fields unchanged.

The SCF exception assumes that the retention commitment is managed through the owning institution’s item and its NZ-linked bib.

---

##### If results exist

- If the barcode identifies an item, the subworkflow updates that item’s `committed_to_retain` and `retention_reason` fields in the selected Institution Zone.
- If the item’s bib is linked to the Network Zone and the institution is not `01WRLC_SCF`, the subworkflow also looks for a 583 field whose $x matches the barcode. If found, it removes that field and updates the NZ bib.
- Results are returned to the calling workflow; no separate notification is sent.

##### If no results exist

- If the barcode does not identify an item, no retention fields are cleared. The item retrieval node is configured to continue on error, but the following code expects an item record, so the parent workflow should not assume the removal succeeded.
- If the bib is not linked to the NZ, or the institution is `01WRLC_SCF`, the item update can still occur; the NZ bib path is skipped.
- If no 583 $x matches the barcode, no 583 field is removed.

---

#### Artifacts produced

- An updated Alma item record.
- When eligible, an updated Network Zone bibliographic record without a corresponding 583 field.
- No files, sets, spreadsheets, or email notifications.