# Module: batch\_script

## BatchScriptingContext

### Attributes:

| Datatype                                                                                                                                                      | Name          | Description                                                                                     | Read-only |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------------------------------------- | --------- |
| *Array*                                                                                                                                                       | errorMessages | Fehlermeldungen, die im Laufe der Skriptverarbeitung aufgetreten sind                           | No        |
| [BatchScriptingContext$BatchScriptImportSession](https://developer.vario-software.de/scripting-reference/types#BatchScriptingContextBatchScriptImportSession) | importSession | Enthält Informationen, welche innerhalb von Skripten eines Import-Laufs verwendet werden können | No        |
| [ImportDataMap](https://developer.vario-software.de/scripting-reference/types#ImportDataMap)                                                                  | importData    | eingelesene Import-Daten                                                                        | Yes       |
| [ScriptingServiceList](https://developer.vario-software.de/scripting-reference/services#ScriptingServiceList)                                                 | services      | Services                                                                                        | Yes       |
| *Map\<string,object>*                                                                                                                                         | parameters    | Parameter zur Verwendung im Skript                                                              | No        |

## BatchScriptAction

Die in der Stapelverarbeitung auszuführende Aktion

*Return type:* *boolean*

| Datatype                                        | Name | Description    | Required |
| ----------------------------------------------- | :--: | -------------- | -------- |
| [BatchScriptingContext](#BatchScriptingContext) |  ctx | Import-Kontext | Yes      |

## BatchScriptAfterbatch

Wird nach dem Import ausgeführt

| Datatype                                        | Name | Description    | Required |
| ----------------------------------------------- | :--: | -------------- | -------- |
| [BatchScriptingContext](#BatchScriptingContext) |  ctx | Import-Kontext | Yes      |

## BatchScriptGuard

Definiert, ob die Aktion ausgeführt werden soll

*Return type:* *boolean*

| Datatype                                        | Name | Description    | Required |
| ----------------------------------------------- | :--: | -------------- | -------- |
| [BatchScriptingContext](#BatchScriptingContext) |  ctx | Import-Kontext | Yes      |

## Instance: batchAction

### Description

Aktionen innerhalb einer Stapelverarbeitung

### Methods

***setAction***

Setter für Callback "action"

| Datatype                                |   Name   | Description       | Required |
| --------------------------------------- | :------: | ----------------- | -------- |
| [BatchScriptAction](#BatchScriptAction) | callback | Callback "action" | Yes      |

***setGuard***

Setter für Callback "guard"

| Datatype                              |   Name   | Description      | Required |
| ------------------------------------- | :------: | ---------------- | -------- |
| [BatchScriptGuard](#BatchScriptGuard) | callback | Callback "guard" | Yes      |

***setAfterBatch***

Setter für Callback "afterBatch"

| Datatype                                        |   Name   | Description           | Required |
| ----------------------------------------------- | :------: | --------------------- | -------- |
| [BatchScriptAfterbatch](#BatchScriptAfterbatch) | callback | Callback "afterBatch" | Yes      |

```
import batchAction from "batch_script";

batchAction.setGuard( (ctx) => {
    // Should the action be performed for the current import record?
    return true;
});

batchAction.setAction( (ctx) => {
    // Execute action for the current import record. true/false for success/failure.
    return true
});

batchAction.setAfterBatch( (ctx) => {
    // Action to be performed after an import block
});

```
