---
title: Imaging system management
summary: Manages IMGSYS records that own image TOWID references, and the batch-level indexing worklist built on top of IMGSYS.
status: draft
owner: <owner>
last_reviewed: 2026-07-30
library: SAIF.Business.Imaging
reference_type: package
operation_id: OP-IMG-07
trigger: Caller creates, retrieves, updates, or deletes a clsImgsys, clsIndexBatch, or clsIndexBatchCollection instance
---

# Imaging system management

`IMGSYS` is the low-level table that owns each image's `TOWID` (tower/image-object reference). `clsImgsys` manages individual `IMGSYS` rows, while `clsIndexBatch` and `clsIndexBatchCollection` build a batch-oriented worklist view over `IMGSYS` for the manual document-indexing process, excluding batches created by automated import pipelines.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-IMG-07 |
| **Trigger** | Caller creates a new `clsImgsys` row, retrieves an `IMGSYS` row by `TOWID` (`clsImgsys`) or a batch summary by batch ID (`clsIndexBatch`), retrieves the active batch list (`clsIndexBatchCollection`), or updates/deletes a batch |
| **Inputs** | `IMGSYS` field values (`BATID`, `CRTRID`, `SLEVEL`, `NPAGES`, `IFNDS`, `IFNID`, etc.); for batch retrieval, a `BATID` |
| **Outputs** | Persisted `IMGSYS` row (create/update), a populated `clsIndexBatch`/`clsIndexBatchCollection` (retrieve), or a soft-deleted batch (delete) |
| **Primary components** | `clsImgsys.BeforeCreate`, `clsImgsys.BeforeInsert`, `clsIndexBatch.BeforeRetrieve`, `clsIndexBatch.BeforeUpdate`, `clsIndexBatch.BeforeDelete`, `clsIndexBatchCollection.BeforeRetrieve` |
| **Entry point** | `Business\SAIF.Business.Imaging\clsImgsys.vb`, `Business\SAIF.Business.Imaging\clsIndexBatch.vb`, `Business\SAIF.Business.Imaging\clsIndexBatchCollection.vb` |

## Steps

1. **Caller provides `IMGSYS` field values** to `clsImgsys` or `clsIndexBatch`.
2. **Generate the TOWID.** `clsImgsys.BeforeCreate` executes [SQL-003](../sql/SQL-003-saif-business-imaging.md) to obtain the next value from `tower.TOWER_SEQ.nextval` ([DUAL](../database-tables.md#dual)); `AfterCreate` defaults `Idxfl = "N"`, sets `Scandt`/`Updtts` to now, sets `Crtrid`/`Updrid` from the create user (or the data-portal user ID if not supplied), and reads the generated `TOWID` into the record.
3. **Insert the IMGSYS row.** `BeforeInsert` executes [SQL-012](../sql/SQL-012-saif-business-imaging.md) to insert into [IMGSYS](../database-tables.md#imgsys).
4. **Retrieve a single IMGSYS row.** `clsImgsys.BeforeRetrieve` executes [SQL-030](../sql/SQL-030-saif-business-imaging.md) by `TOWID`.
5. **Retrieve a batch summary.** `clsIndexBatch.BeforeRetrieve` executes [SQL-031](../sql/SQL-031-saif-business-imaging.md) to retrieve non-indexed, non-deleted `IMGSYS` rows grouped by batch ID.
6. **Retrieve the active batch list.** `clsIndexBatchCollection.BeforeRetrieve` executes [SQL-032](../sql/SQL-032-saif-business-imaging.md), which excludes indexed (`IDXFL <> 'N'`) rows, deleted (`DELCD <> ' '`) rows, and any batch whose uppercased `BATID` is `AUTOIMPORT` or `FAXIMPORT` ([BR-IMG-06](../business-rules.md#br-img-06-index-batch-retrieval-excludes-automated-import-batches)).
7. **Update batch fields.** `clsIndexBatch.BeforeUpdate` executes [SQL-038](../sql/SQL-038-saif-business-imaging.md) to update `SCANDT` and `BATID` for the batch's rows.
8. **Soft-delete a batch.** `clsIndexBatch.BeforeDelete` executes [SQL-044](../sql/SQL-044-saif-business-imaging.md), setting `DELCD` rather than physically removing the `IMGSYS` rows.
9. **Verify lifecycle operations.** `AfterInsert`/`AfterUpdate` on `clsImgsys` and `clsIndexBatch` enforce exactly-one-row-affected checks and raise error messages on failure, following the same pattern used across the library's other business objects.

## Process flow

The following diagram visualizes the imaging system management flow, including the batch worklist exclusion of automated-import batches.

```mermaid
flowchart TD
	Start([Caller provides IMGSYS<br>field values]) --> Which{Which action?}
	Which -->|Create| GenTow[BeforeCreate: generate TOWID]
	GenTow --> Insert[BeforeInsert: INSERT row]
	Insert --> Check{AfterInsert:<br>exactly 1 row?}
	Check -->|No| Error([Error raised])
	Check -->|Yes| DoneI([IMGSYS row created])
	Which -->|Retrieve one| RetrieveOne[BeforeRetrieve by TOWID]
	RetrieveOne --> DoneR([IMGSYS row loaded])
	Which -->|Retrieve batch summary| RetrieveBatch[BeforeRetrieve by BATID]
	RetrieveBatch --> DoneB([Batch summary loaded])
	Which -->|Retrieve active batch list| RetrieveList[BeforeRetrieve: non-indexed,<br>non-deleted, excl. AUTOIMPORT/FAXIMPORT]
	RetrieveList --> DoneL([Active batch list loaded])
	Which -->|Update| Update[BeforeUpdate: update SCANDT/BATID]
	Update --> DoneU([Batch updated])
	Which -->|Delete| SoftDelete[BeforeDelete: set DELCD]
	SoftDelete --> DoneD([Batch soft-deleted])
```

## Failure and edge-case behavior

- `AfterInsert`/`AfterUpdate` methods on `clsImgsys` and `clsIndexBatch` enforce exactly-one-row-affected checks and raise error messages on failure.
- `clsIndexBatch.BeforeDelete` performs a soft delete (setting `DELCD`) rather than a physical row removal, so deleted batches remain in `IMGSYS` but are excluded from subsequent active-batch queries.
- `clsIndexBatchCollection.BeforeRetrieve` excludes batches with `BATID` `AUTOIMPORT` or `FAXIMPORT` from the manual indexing worklist regardless of their indexed/deleted state otherwise matching ([BR-IMG-06](../business-rules.md#br-img-06-index-batch-retrieval-excludes-automated-import-batches)).

## Related documentation

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

## Sources

- `Business\SAIF.Business.Imaging\clsImgsys.vb`
- `Business\SAIF.Business.Imaging\clsIndexBatch.vb`
- `Business\SAIF.Business.Imaging\clsIndexBatchCollection.vb`
