# expectationOperation

**Kind:** Class

**Source:** `Pams/Web/Pams.WebApp/Client/app/core/models/dashboard-data-fields.ts` (line 172)

**Part of:** [Pams](subsystem-pams)

`expectationOperation` holds metadata for an expected dashboard data field, including its stored name, field name, caption, expected field type, and data type. Dashboard code can read this metadata through getters and check `isHidden()` when deciding whether to display the field.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `SetStoredName` | `SetStoredName(name: string)` | `void` |
| `GetFieldName` | `GetFieldName()` | `string` |
| `SetFieldName` | `SetFieldName(name: string)` | `void` |
| `GetType` | `GetType()` | `expectedFieldType` |
| `SetType` | `SetType(type: expectedFieldType)` | `void` |
| `GetCaption` | `GetCaption()` | `string` |
| `SetCaption` | `SetCaption(input: string)` | `void` |
| `SetDataType` | `SetDataType(ty: DataTypeEnum)` | `void` |
| `GetDataType` | `GetDataType()` | `DataTypeEnum` |
| `isHidden` | `isHidden()` | `boolean` |
| `setHidden` | `setHidden(flag: boolean)` | `void` |

## Properties

| Property | Type |
|---|---|
| `callback` | `callbackPRAny` |
| `CertainYear` | `number` |
| `GetStoredName` | `any` |

## Where it refuses work

- `expectationOperation` stops the work with an early return when `this.Field.StoredName`.
- `expectationOperation` stops the work with an early return when `this.Field.FieldName`.

## Diagram

```mermaid
graph LR
  Dashboard[Dashboard data consumer] --> Operation[expectationOperation]
  Operation --> StoredName[Stored name]
  Operation --> FieldName[Field name]
  Operation --> Caption[Caption]
  Operation --> FieldType[expectedFieldType]
  Operation --> DataType[DataTypeEnum]
  Operation --> Visibility[isHidden()]
```

## Usage

```ts
import {
  expectationOperation,
  expectedFieldType,
  DataTypeEnum,
} from "./core/models/dashboard-data-fields";

function configureExpectedField(
  type: expectedFieldType,
  dataType: DataTypeEnum,
): expectationOperation {
  const field = new expectationOperation();

  field.SetFieldName("customerName");
  field.SetCaption("Customer name");
  field.SetType(type);
  field.SetDataType(dataType);
  field.SetStoredName();

  if (!field.isHidden()) {
    console.log(`${field.GetCaption()}: ${field.GetFieldName()}`);
  }

  return field;
}
```

## AI Coding Instructions

- Set the field name, caption, expected field type, and data type before passing an `expectationOperation` instance to dashboard consumers.
- Pass values from `expectedFieldType` and `DataTypeEnum` rather than raw strings when calling `SetType()` and `SetDataType()`.
- Read metadata through `GetFieldName()`, `GetCaption()`, `GetType()`, and `GetDataType()` instead of duplicating field configuration elsewhere.
- Check `isHidden()` in rendering or filtering code instead of assuming every configured field should be displayed.
