> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# NSBatchAgent

> Start, stop and monitor predefined batch tasks.

Start, stop and monitor predefined batch tasks.

## Constructors

### NSBatchAgent()

```crmscript theme={null}
NSBatchAgent
```

Initializes a new instance of the NSBatchAgent class.

## Methods

## DeleteBatchTask(Integer)

Deletes a batch task from the database.

```crmscript theme={null}
Void DeleteBatchTask(Integer batchTaskId)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## DeleteBatchTasks(Integer\[])

Deletes batch tasks from the database.

```crmscript theme={null}
Void DeleteBatchTasks(Integer[] batchTaskIds)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## GetBatchTaskInfo(Integer)

Gets a single NSBatchTaskInfo based on ID.

```crmscript theme={null}
NSBatchTaskInfo GetBatchTaskInfo(Integer id)
```

**Returns:** [CRMScript.NetServer.NSBatchTaskInfo](CRMScript.NetServer.NSBatchTaskInfo) - A BatchTaskInfo.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
Integer id;
NSBatchTaskInfo res = agent.GetBatchTaskInfo(id);
```

## GetBatchTaskInfosByAssociates(Integer\[])

Gets an array of NSBatchTaskInfo for the provided associate IDs.

```crmscript theme={null}
NSBatchTaskInfo[] GetBatchTaskInfosByAssociates(Integer[] associateIds)
```

**Returns:** [CRMScript.NetServer.NSBatchTaskInfo](CRMScript.NetServer.NSBatchTaskInfo)\[] - An array of BatchTaskInfo.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
Integer[] associateIds;
NSBatchTaskInfo[] res = agent.GetBatchTaskInfosByAssociates(associateIds);
```

## GetBatchTaskInfosByAssociatesAndState(Integer\[],Integer)

Gets an array of NSBatchTaskInfo for the provided associate IDs and batch task state.

```crmscript theme={null}
NSBatchTaskInfo[] GetBatchTaskInfosByAssociatesAndState(Integer[] associateIds, Integer state)
```

**Returns:** [CRMScript.NetServer.NSBatchTaskInfo](CRMScript.NetServer.NSBatchTaskInfo)\[] - An array of BatchTaskInfo.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
Integer[] associateIds;
Integer state;
NSBatchTaskInfo[] res = agent.GetBatchTaskInfosByAssociatesAndState(associateIds, state);
```

## GetBatchTaskInfosByNameAndAssociates(String,Integer\[])

Gets an array of NSBatchTaskInfo for the provided associate IDs and batch task definition name.

```crmscript theme={null}
NSBatchTaskInfo[] GetBatchTaskInfosByNameAndAssociates(String name, Integer[] associateIds)
```

**Returns:** [CRMScript.NetServer.NSBatchTaskInfo](CRMScript.NetServer.NSBatchTaskInfo)\[] - An array of BatchTaskInfo.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
String name;
Integer[] associateIds;
NSBatchTaskInfo[] res = agent.GetBatchTaskInfosByNameAndAssociates(name, associateIds);
```

## GetBatchTaskInfosByNameAndState(String,Integer)

Gets an array of NSBatchTaskInfo with state defined by a BatchTaskState and the batchtask definition name.

```crmscript theme={null}
NSBatchTaskInfo[] GetBatchTaskInfosByNameAndState(String name, Integer state)
```

**Returns:** [CRMScript.NetServer.NSBatchTaskInfo](CRMScript.NetServer.NSBatchTaskInfo)\[] - An array of BatchTaskInfo.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
String name;
Integer state;
NSBatchTaskInfo[] res = agent.GetBatchTaskInfosByNameAndState(name, state);
```

## GetBatchTaskInfosByState(Integer)

Gets an array of NSBatchTaskInfo with state defined by a BatchTaskState.

```crmscript theme={null}
NSBatchTaskInfo[] GetBatchTaskInfosByState(Integer state)
```

**Returns:** [CRMScript.NetServer.NSBatchTaskInfo](CRMScript.NetServer.NSBatchTaskInfo)\[] - An array of BatchTaskInfo.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
Integer state;
NSBatchTaskInfo[] res = agent.GetBatchTaskInfosByState(state);
```

## StartBatchJob(NSBatchTaskInfo)

Starts a batch job based on NSBatchTaskInfo.

```crmscript theme={null}
Integer StartBatchJob(NSBatchTaskInfo batchTaskInfo)
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The ID of the created batch job.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
NSBatchTaskInfo batchTaskInfo;
Integer res = agent.StartBatchJob(batchTaskInfo);
```

## StopBatchJob(Integer)

Stops a batch job based on ID.

```crmscript theme={null}
Bool StopBatchJob(Integer id)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - true if the job was stopped successfully.

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
Integer id;
Bool res = agent.StopBatchJob(id);
```

## UpdateBatchTask(NSBatchTaskInfo)

Updates information about a BatchTask.

```crmscript theme={null}
NSBatchTaskInfo UpdateBatchTask(NSBatchTaskInfo batchTaskInfo)
```

**Returns:** [CRMScript.NetServer.NSBatchTaskInfo](CRMScript.NetServer.NSBatchTaskInfo) - The updated BatchTaskInfo.

<Note>
  Only the following properties can be updated: State, Description, Response and Request.
</Note>

**Example:**

```crmscript theme={null}
NSBatchAgent agent;
NSBatchTaskInfo batchTaskInfo;
NSBatchTaskInfo res = agent.UpdateBatchTask(batchTaskInfo);
```


## Related topics

- [Namespace CRMScript.NetServer](/en/automation/crmscript/reference/CRMScript.NetServer.md)
- [SuperOffice.WebApi.Agents.BatchAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.BatchAgent.md)
- [SuperOffice.WebApi.Agents.IBatchAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.IBatchAgent.md)
- [Batch Reply](/en/api/reference/restful/agent/ticket_agent/batch-reply.md)
- [Batch Forward](/en/api/reference/restful/agent/ticket_agent/batch-forward.md)
- [Start Batch Job](/en/api/reference/restful/agent/batch_agent/start-batch-job.md)
