---
title: Generate batch claim tasks
summary: Builds one or more claim tasks against a claim ID or worker-shared claim context, computing the assignee, due date, category, and priority, then saves the whole batch as a unit.
status: draft
owner: SAIF
last_reviewed: 2026-07-30
library: SAIF.Business.Tasks.Claim
reference_type: package
operation_id: OP-TC-04
trigger: Caller constructs a clsClaimTaskGenerator, calls one or more AddTask overloads, and calls Save
---

# Generate batch claim tasks

`clsClaimTaskGenerator` is a `clsBusinessBase` orchestration object — not a task itself — that wraps an internal `clsClaimTaskCollection` and provides a family of `AddTask` overloads for building one or more claim tasks with sensible defaults (next working day, medium priority, "manage claim" category, assignee inferred from the responsible adjuster). It can be scoped to a single claim at construction or left unscoped so each `AddTask` call supplies its own claim ID, and it validates every task it builds with a level-three claim-ID rule before a single `Save()` persists the whole batch through the wrapped collection.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-TC-04 |
| **Trigger** | Caller constructs `New clsClaimTaskGenerator(dpi[, claimId or claimNumber or claimData][, createUser])`, calls one or more `AddTask` overloads, then calls `Save()` |
| **Inputs** | `IDataPortalInfo`; optional default claim (by `ClaimID`, claim number, or `clsClaimData`) and create user; per-task text, optional assignee mail ID, due date or offset, `TaskPriority`, `clsClaimTask.ClaimCategories`, and notepad-required flag |
| **Outputs** | Populated `Tasks` (`clsClaimTaskCollection`); `IsValid`, `IsDirty`, `ErrorMessages`, and `ErrorCount` mirrored from the inner collection; `Save()` boolean result; `ToXML()`/`GetReportXML()` projections of the batch |
| **Primary components** | `clsClaimTaskGenerator.New`, `clsClaimTaskGenerator.AddTask` (nine overloads), `clsClaimTaskGenerator.NewTask` (private), `clsClaimTaskGenerator.IsValidClaimID`, `clsClaimTaskGenerator.Save`, `clsClaimTaskGenerator.GetPriorityText` |
| **Entry point** | `Business\SAIF.Business.Tasks.Claim\clsClaimTaskGenerator.vb` |

## Steps

1. **Construct the generator.** `Initialize()` (called from every constructor overload) creates the wrapped `clsClaimTaskCollection` via `NewTaskCollection(dpi)` (see [Retrieve claim tasks](retrieve-claim-tasks.md) for that collection's retrieval mechanics, which also apply to its empty-collection construction) and defaults `CreateUser` to `dpi.UserID` when the caller did not supply one.
   - The five constructor overloads differ only in how the default claim context is established: no default claim (`ClaimID = 0`); a create-user override with no default claim; an explicit `ClaimID`; a claim number resolved through `clsClaimData.GetData` (silently leaving no default claim if the claim is invalid); or a pre-resolved `clsClaimData`.

     > **Origin**: `clsClaimData.GetData` is implemented in `SAIF.Business.View.Claim`. That library is documented in the previous format, so no per-operation page exists; see [Operations and processes](../../saif-business-view-claim/operations-processes.md) in the `SAIF.Business.View.Claim` documentation set.
2. **Add one or more tasks.** Nine public `AddTask` overloads all normalize their arguments and delegate to the private `NewTask(claimId, user, text, dueDate, priority, claimCategory, notePadRequired)`:
   - Overloads that omit a claim ID use the generator's default `m_ClaimID`; overloads that omit a due date use `New clsSmartDate(Today()).NextWorkDay` (today rolled forward to the next working day); overloads that take a due-date offset roll the date forward or back by that many days, snapping to the previous working day if the target lands on a non-workday.
   - `NewTask` throws an `ApplicationException("ClaimID not specified")` if the resolved claim ID is `0`.
   - It creates the task via `clsClaimTask.NewTask(dpi, claimId, m_CreateUser)` (see [Claim task lifecycle](claim-task-lifecycle.md) for the create/enrich steps this triggers).
   - If no assignee was supplied: it resolves one via `ClaimServices.GetResponsibleAdjuster(dpi, claimId)` when the generator has no default `clsClaimData`, or via the cached `m_ClaimData.AdjusterMailID` when it does.

     > **Origin**: `ClaimServices.GetResponsibleAdjuster` is implemented in `SAIF.BOF.Business`; see [ClaimServices](../../saif-business/api/SAIF.Business/claimservices.md) in the `SAIF.BOF.Business` documentation set.
   - If `notePadRequired` is true: it sets the task's notepad flag to `"Y"` via `setNotePadFlag`.
   - If the generator has a default `clsClaimData`: it copies `PolicyNumber` onto the task.
   - It sets `MailID`, `Text`, `PriorityCode` (via `GetPriorityText`), and `TaskDate` on the task.
   - It sets `CategoryCode` to `clsClaimTask.FASTTRACKCATEGORY` when `inClaimCategory = FastTrack`, otherwise `clsClaimTask.DEFAULTCATEGORY`.
   - It registers the `IsValidClaimID` rule on the new task ([BR-009](../business-rules.md#br-009-batch-task-generation-requires-a-valid-claim-id)) and adds the task to the wrapped `m_Collection`.
3. **Validate.** `IsValidClaimID` ([BR-009](../business-rules.md#br-009-batch-task-generation-requires-a-valid-claim-id)) resolves `clsClaimData.GetData(m_DPI, task.ClaimID)` for the specific task and returns whether that claim's `IsValid` is true, at rule-check level three.
4. **Inspect batch state.** `Count`, `IsValid`, `IsDirty`, `ErrorMessages`, and `ErrorCount` all delegate directly to the wrapped `m_Collection`, giving the caller a single surface for the whole batch's status before saving.
5. **Save the batch.** `Save()` calls `m_Collection.Save()`, persisting every task added since construction through the inherited BOF task save pipeline in one call.

   > **Origin**: Insert, update, and soft-delete persistence for each task's underlying `TASK` row, and the collection-level save orchestration, are implemented by `clsTask`/`clsTaskCollection` in `SAIF.Business.Tasks`. That library is documented in the previous format, so no per-operation page exists; see [Insert task](../../saif-business-tasks/operations/task-record-lifecycle.md) and [Update task](../../saif-business-tasks/operations/task-record-lifecycle.md) in the `SAIF.Business.Tasks` documentation set.
6. **Export.** `ToXML()` and `GetReportXML()` return XML and report-XML projections of the wrapped collection, unchanged from the base task-collection serialization.

## Process flow

The following diagram visualizes constructing a generator, adding tasks, and saving the batch.

```mermaid
flowchart TD
	Start([New clsClaimTaskGenerator]) --> Init[Initialize: create<br>inner clsClaimTaskCollection]
	Init --> AddCall[Caller calls an AddTask overload]
	AddCall --> Normalize[Normalize claimId, dueDate,<br>priority, category]
	Normalize --> ClaimCheck{ClaimID resolved<br>and non-zero?}
	ClaimCheck -->|No| Throw([ApplicationException:<br>ClaimID not specified])
	ClaimCheck -->|Yes| CreateTask[clsClaimTask.NewTask]
	CreateTask --> Assignee{MailID supplied?}
	Assignee -->|No| ResolveAdjuster[Resolve responsible adjuster<br>or use cached ClaimData.AdjusterMailID]
	Assignee -->|Yes| SetFields[Set MailID, Text, Priority,<br>TaskDate, CategoryCode]
	ResolveAdjuster --> SetFields
	SetFields --> RegisterRule[Register IsValidClaimID rule]
	RegisterRule --> AddToCollection[Add task to inner collection]
	AddToCollection --> More{More AddTask calls?}
	More -->|Yes| AddCall
	More -->|No| SaveCall[Caller calls Save]
	SaveCall --> Persist[Inner collection.Save:<br>inherited task save pipeline]
	Persist --> Done([Save returns success/failure])
```

## Failure and edge-case behavior

- `NewTask` throws an `ApplicationException` immediately if a resolved claim ID is `0`; this is a hard failure, not a validation warning, so a batch that includes one bad claim ID can abort task creation before any `Save()` is attempted.
- Constructing the generator from an invalid claim number silently leaves no default claim rather than raising an error; subsequent `AddTask` overloads that rely on the default claim ID will then fail with the "ClaimID not specified" exception.*
- `IsValidClaimID` re-resolves `clsClaimData` per task at validation time, independent of whatever claim data the generator cached at construction, so a claim that becomes invalid between generator construction and `Save()` is still caught.
- `Save()` persists the entire batch through a single collection save; a per-task contention or validation failure surfaces through the collection's `ErrorCount`/`ErrorMessages`, not as a per-task return value from `AddTask`.
- Overloads that specify a due-date offset roll a non-workday target to the previous working day, while overloads that specify only a due date roll a non-workday target forward to the next working day — callers must pick the right overload to get the intended rounding direction.

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

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts.

## Sources
- `Business\SAIF.Business.Tasks.Claim\clsClaimTaskGenerator.vb`
