> ## 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.

# NSNumberAllocationAgent

> This agent can be used to manage number allocation.

This agent can be used to manage number allocation.

## Constructors

### NSNumberAllocationAgent()

```crmscript theme={null}
NSNumberAllocationAgent
```

This agent can be used to manage number allocation.

## Methods

## CreateDefaultRefCountEntity()

Sets default values into a new NSRefCountEntity.

```crmscript theme={null}
NSRefCountEntity CreateDefaultRefCountEntity()
```

**Returns:** [CRMScript.NetServer.NSRefCountEntity](CRMScript.NetServer.NSRefCountEntity)

<Note>
  NetServer calculates default values (for example, Country) on the entity, which is required when creating/storing a new instance
</Note>

**Example:**

```crmscript theme={null}
NSNumberAllocationAgent agent;
NSRefCountEntity thing = agent.CreateDefaultRefCountEntity();
thing = agent.SaveRefCountEntity(thing);
```

## DeleteRefCountEntity(Integer)

Deletes the NSRefCountEntity

```crmscript theme={null}
DeleteRefCountEntity(Integer refCountEntity)
```

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

**Example:**

```crmscript theme={null}
NSNumberAllocationAgent agent;
agent.DeleteRefCountEntity(123);
```

## GetNumberEachTemplate()

Returns true or false if Automatically create new counters for new document templates

```crmscript theme={null}
Bool GetNumberEachTemplate()
```

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

**Example:**

```crmscript theme={null}
NSNumberAllocationAgent agent;
Bool res = agent.GetNumberEachTemplate();
```

## GetRefCountEntity(Integer)

Gets an NSRefCountEntity object.

```crmscript theme={null}
NSRefCountEntity GetRefCountEntity(Integer refCountEntityId)
```

**Returns:** [CRMScript.NetServer.NSRefCountEntity](CRMScript.NetServer.NSRefCountEntity)

**Example:**

```crmscript theme={null}
NSNumberAllocationAgent agent;
NSRefCountEntity thing = agent.GetRefCountEntity(123);
```

## SaveDefaultNumbering(NSRefCountEntity)

Saves default numbering values in preferences

```crmscript theme={null}
Void SaveDefaultNumbering(NSRefCountEntity refCountEntity)
```

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

**Example:**

```crmscript theme={null}
NSNumberAllocationAgent agent;
NSRefCountEntity refCountEntity;
agent.SaveDefaultNumbering(NSRefCountEntity);
```

## SaveRefCountEntity(NSRefCountEntity)

Updates the existing NSRefCountEntity or creates a new NSRefCountEntity if the id parameter is 0

```crmscript theme={null}
NSRefCountEntity SaveRefCountEntity(NSRefCountEntity refCountEntity)
```

**Returns:** [CRMScript.NetServer.NSRefCountEntity](CRMScript.NetServer.NSRefCountEntity)

**Example:**

```crmscript theme={null}
NSNumberAllocation  agent;
NSRefCountEntity thing = agent.CreateDefaultRefCountEntity();
thing = agent.SaveRefCountEntity(thing);
```

## SetNumberEachTemplate(Bool)

Saves true or false if Automatically create new counters for new document templates

```crmscript theme={null}
Void SetNumberEachTemplate(Bool setValue)
```

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

**Example:**

```crmscript theme={null}
NSNumberAllocationAgent agent;
Bool setValue;
agent.SetNumberEachTemplate(setValue);
```


## Related topics

- [SuperOffice.WebApi.Agents.NumberAllocationAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.NumberAllocationAgent.md)
- [SuperOffice.WebApi.Agents.INumberAllocationAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.INumberAllocationAgent.md)
- [Specifying number allocation](/en/admin/options/configure-number-allocation.md)
- [Travel number allocation](/en/onsite/travel/number-allocation.md)
- [Numbers](/en/api/archive-providers/reference/numbers.md)
- [Set Number Each Template](/en/api/reference/restful/agent/numberallocation_agent/set-number-each-template.md)
