---
title: Generate claim tasks
summary: Creates a single-claim or multi-claim task generator and optionally saves the generated to-do tasks.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-30
library: SAIF.Application.Claim
reference_type: package
operation_id: OP-AC-05
trigger: Subclass calls NewTaskGenerator, optionally followed by SaveTasks
---

# Generate claim tasks

This operation creates a `clsClaimTaskGenerator` bound either to the claim currently in context or to multiple claims, and optionally persists whatever tasks the generator produces. It is a helper used by concrete `ClaimAppManager` subclasses rather than something triggered directly by an external caller.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-AC-05 |
| **Trigger** | Subclass code calls `NewTaskGenerator(inMultiClaim)` and later `SaveTasks()` |
| **Inputs** | `inMultiClaim` flag; the active `ClaimData` (for single-claim mode); the data portal (`DPI`) |
| **Outputs** | Populated `clsClaimTaskGenerator` (`Tasks`); Boolean save result |
| **Primary components** | `ClaimAppManager.NewTaskGenerator`, `ClaimAppManager.SaveTasks`, `clsClaimTaskGenerator` |
| **Entry point** | `Application\SAIF.Application.Claim\ClaimAppManager.vb` |

## Steps

1. `NewTaskGenerator(Optional inMultiClaim As Boolean = False)` branches on `inMultiClaim`:
   - If true: assigns `m_Tasks = New clsClaimTaskGenerator(DPI)`, a generator that is not bound to the claim currently in context and is intended to create tasks across multiple claims.
   - If false (default): assigns `m_Tasks = New clsClaimTaskGenerator(DPI, ClaimData)`, a generator bound to the single claim in context.
   - Sub-step: `clsClaimTaskGenerator`'s constructor and generation logic are implemented in `SAIF.Business.Tasks.Claim`.

     > **Origin**: Batch and single-claim task generation is implemented by `clsClaimTaskGenerator` in `SAIF.Business.Tasks.Claim`. That library is documented in the previous format, so no per-operation page exists; see [Generate batch claim tasks](../../saif-business-tasks-claim/operations/generate-batch-claim-tasks.md) in the `SAIF.Business.Tasks.Claim` documentation set.
2. `SaveTasks()` checks `Tasks.Count > 0`.
   - If tasks exist: calls `Tasks.Save()`, then returns `Tasks.ErrorCount = 0` as the save outcome.
     - Sub-step: `Tasks.Save()` persists the generated task rows and accumulates any validation errors on the collection.

       > **Origin**: Task persistence follows the inherited entity save lifecycle documented for `clsClaimTaskGenerator`'s base type in `SAIF.Business.Tasks.Claim` (from `clsBusinessBase`, `saif-framework-core`). That library is documented in the previous format, so no per-operation page exists; see [Save entity lifecycle (inherited)](../../saif-business-tasks-claim/operations/claim-task-lifecycle.md) in the `SAIF.Business.Tasks.Claim` documentation set.
   - If no tasks exist (`Tasks.Count = 0`): `SaveTasks()` returns `True` without calling `Save()` — an empty task set is treated as a successful no-op.

## Process flow

The following diagram visualizes generator creation and the conditional save.

```mermaid
flowchart TD
	Start([Subclass requests task generation]) --> Mode{inMultiClaim?}
	Mode -->|True| Multi[New clsClaimTaskGenerator DPI<br>multi-claim mode]
	Mode -->|False| Single[New clsClaimTaskGenerator DPI, ClaimData<br>single-claim mode]
	Multi --> Ready[Tasks populated on manager]
	Single --> Ready
	Ready --> SaveCall{SaveTasks called?}
	SaveCall -->|No| Deferred([Tasks remain unsaved])
	SaveCall -->|Yes| Count{Tasks.Count > 0?}
	Count -->|No| NoOp([Return True; nothing saved])
	Count -->|Yes| DoSave[Tasks.Save]
	DoSave --> ErrCheck{Tasks.ErrorCount = 0?}
	ErrCheck -->|Yes| Success([Return True])
	ErrCheck -->|No| Failure([Return False])
```

## Failure and edge-case behavior

- `SaveTasks()` treats an empty task collection as success (`True`) rather than as a no-op failure or a distinguishable "nothing to do" result — callers cannot tell from the return value alone whether tasks were actually saved.*
- `SaveTasks()`'s success determination depends entirely on `Tasks.ErrorCount`, which is populated by `clsClaimTaskGenerator.Save()` in `SAIF.Business.Tasks.Claim`; any validation or persistence failures inside that call surface only through the error count, not through a thrown exception at this layer.*
- Calling `NewTaskGenerator(True)` (multi-claim mode) without a valid `DPI` would leave the generator unable to resolve claims to attach tasks to, since no single `ClaimData` is bound in that mode.*

## Related documentation

- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.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

- `Application\SAIF.Application.Claim\ClaimAppManager.vb`
