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

# SuperOffice.WebApi.Agents.IViewStateAgent

# \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent">\</a> Interface IViewStateAgent

Namespace: [SuperOffice.WebApi.Agents](SuperOffice.WebApi.Agents.md)\
Assembly: SuperOffice.WebApi.dll

User interface view state, history, currentXXX values

```csharp theme={null}
public interface IViewStateAgent : IAgentBase, IDisposable
```

#### Implements

[IAgentBase](SuperOffice.WebApi.Agents.IAgentBase.md),
[IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

## Methods

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_DeleteHistoryAsync\_System\_String\_System\_Int32\_SuperOffice\_WebApi\_RequestOptions\_">\</a> DeleteHistoryAsync(string, int, RequestOptions)

Deletes the history element

```csharp theme={null}
Task DeleteHistoryAsync(string historyName, int id, RequestOptions requestOptions = null)
```

#### Parameters

`historyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of the history list, e.g. contact, project

`id` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Id of the history element, e.g. Contact id

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task)

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetCurrentAsync\_System\_String\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetCurrentAsync(string, RequestOptions)

Get the current (most recent) value of the history list. This is the item with rank = 1. If no item exists a default value is returned. This is usually the first item in the table representing the history list.

```csharp theme={null}
Task<History> GetCurrentAsync(string historyName, RequestOptions requestOptions = null)
```

#### Parameters

`historyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of the history list, e.g. contact, project

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\&gt;

The current (most recent) history item

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetHistoriesAsync\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetHistoriesAsync(RequestOptions)

Returns all history items that belong to the currently logged in user

```csharp theme={null}
Task<History[]> GetHistoriesAsync(RequestOptions requestOptions = null)
```

#### Parameters

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\[]\&gt;

Array of History items

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetHistoriesByNameAsync\_System\_String\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetHistoriesByNameAsync(string, RequestOptions)

Returns the named history list that belong to the currently logged in user

```csharp theme={null}
Task<History[]> GetHistoriesByNameAsync(string historyName, RequestOptions requestOptions = null)
```

#### Parameters

`historyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of the history list

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\[]\&gt;

Array of History items

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetHistoriesByNamesAndIdsAsync\_SuperOffice\_WebApi\_Data\_HistoryRequest\_\_\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetHistoriesByNamesAndIdsAsync(HistoryRequest\[], RequestOptions)

Returns history data for the named entities and the given ids - which may not directly correspond to the current history records in the database.\<para/>Use this method if you know exactly which items you need, regardless of whether they are in the current history or not.\<para/>The history in the database is not changed or even looked at by this method.

```csharp theme={null}
Task<History[]> GetHistoriesByNamesAndIdsAsync(HistoryRequest[] requests, RequestOptions requestOptions = null)
```

#### Parameters

`requests` [HistoryRequest](SuperOffice.WebApi.Data.HistoryRequest.md)\[]

Array of request objects that define what entities we are requesting history information for

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\[]\&gt;

On history item for each history name/id pair specified, in exactly the same order as specified.\<para/>If a specified item cannot be found in the database, its Id will be 0 and its name will be blank in the return array.

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetHistoriesByNamesAsync\_System\_String\_\_\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetHistoriesByNamesAsync(string\[], RequestOptions)

Returns the named history lists that belong to the currently logged in user

```csharp theme={null}
Task<History[]> GetHistoriesByNamesAsync(string[] historyNames, RequestOptions requestOptions = null)
```

#### Parameters

`historyNames` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]

String array of list names

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\[]\&gt;

Array of History items

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetHistoryAsync\_System\_Int32\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetHistoryAsync(int, RequestOptions)

Gets a specific History object.

```csharp theme={null}
Task<History> GetHistoryAsync(int historyId, RequestOptions requestOptions = null)
```

#### Parameters

`historyId` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The identifier of the History object

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\&gt;

History

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetHistoryLengthPrefValueAsync\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetHistoryLengthPrefValueAsync(RequestOptions)

Get the logged on user's preferred history list length. Will return the system preference if no user preferences are available.

```csharp theme={null}
Task<int> GetHistoryLengthPrefValueAsync(RequestOptions requestOptions = null)
```

#### Parameters

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[int](https://learn.microsoft.com/dotnet/api/system.int32)\&gt;

The history list lenght

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetLiveUiConfigAsync\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetLiveUiConfigAsync(RequestOptions)

Gets live UI configuration

```csharp theme={null}
Task<LiveUiConfig> GetLiveUiConfigAsync(RequestOptions requestOptions = null)
```

#### Parameters

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[LiveUiConfig](SuperOffice.WebApi.Data.LiveUiConfig.md)\&gt;

Live UI configuration containing the parameters needed for live UI functionality

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetNextCurrentAsync\_System\_String\_System\_Int32\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetNextCurrentAsync(string, int, RequestOptions)

Returns the next current item. If no item exists a default value is returned. This is usually the first item in the table representing the history list.

```csharp theme={null}
Task<History> GetNextCurrentAsync(string historyName, int id, RequestOptions requestOptions = null)
```

#### Parameters

`historyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of the history list, e.g. contact, project

`id` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Id of the history element, e.g. Contact id

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\&gt;

The current value.

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_GetPreviousCurrentAsync\_System\_String\_System\_Int32\_SuperOffice\_WebApi\_RequestOptions\_">\</a> GetPreviousCurrentAsync(string, int, RequestOptions)

Returns the previous current item. If no item exists a default value is returned. This is usually the first item in the table representing the history list.

```csharp theme={null}
Task<History> GetPreviousCurrentAsync(string historyName, int id, RequestOptions requestOptions = null)
```

#### Parameters

`historyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of the history list, e.g. contact, project

`id` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Id of the history element, e.g. Contact id

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\&gt;

The current value.

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_PublishAndRetrieveUiEventsAsync\_System\_Int32\_SuperOffice\_WebApi\_Data\_UiEvent\_\_\_SuperOffice\_WebApi\_Data\_MetricPair\_\_\_SuperOffice\_WebApi\_RequestOptions\_">\</a> PublishAndRetrieveUiEventsAsync(int, UiEvent\[], MetricPair\[], RequestOptions)

Publish zero or more events, and return any new events since the given event id. The initial implementation is in-memory only; applies solely to the front-end web server; and anything older than 20 minutes is discarded

```csharp theme={null}
Task<UiEvent[]> PublishAndRetrieveUiEventsAsync(int latestKnownEventId, UiEvent[] publishEvents, MetricPair[] metrics, RequestOptions requestOptions = null)
```

#### Parameters

`latestKnownEventId` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The last event ID that this client knows about. The return value will be any events occurring /after/ that point, numbered by the server. Clients need to keep track themselves of this number between calls

`publishEvents` [UiEvent](SuperOffice.WebApi.Data.UiEvent.md)\[]

Array of events to publish. This can be empty if the client only wants to retrieve information

`metrics` [MetricPair](SuperOffice.WebApi.Data.MetricPair.md)\[]

Optional statistical and performance metrics collected by the frontend. Can be null or empty. Metrics are sum-accumulated and reported once a minute; please do not report the same logical event twice

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[UiEvent](SuperOffice.WebApi.Data.UiEvent.md)\[]\&gt;

Array of events since the given event ID; within the time span kept by the event mechanism. Event/primarykey combinations are not guaranteed to be unique, and events in the PublishEvents parameter are echoed back to the client

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_SaveCurrentAsync\_SuperOffice\_WebApi\_Data\_History\_SuperOffice\_WebApi\_RequestOptions\_">\</a> SaveCurrentAsync(History, RequestOptions)

Saving the current history item. This history item is saved with Rank = 1, and all the remaining elements rank values are shifted one down. The list is maintained with the max lenght of the History list length preference.

```csharp theme={null}
Task<History> SaveCurrentAsync(History current, RequestOptions requestOptions = null)
```

#### Parameters

`current` [History](SuperOffice.WebApi.Data.History.md)

The new current history element.

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\&gt;

The current (most recent) history item

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_SaveCurrentsAsync\_SuperOffice\_WebApi\_Data\_History\_\_\_SuperOffice\_WebApi\_RequestOptions\_">\</a> SaveCurrentsAsync(History\[], RequestOptions)

Saves the history elements as the current value for their respective lists. If more than one item is submitted for the same list, they are added sequently, meaning that the last one is the most current.

```csharp theme={null}
Task<History[]> SaveCurrentsAsync(History[] currents, RequestOptions requestOptions = null)
```

#### Parameters

`currents` [History](SuperOffice.WebApi.Data.History.md)\[]

Array of new history items to save.

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\[]\&gt;

Array of the saved History items

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_SaveHistoriesAsync\_System\_String\_SuperOffice\_WebApi\_Data\_History\_\_\_SuperOffice\_WebApi\_RequestOptions\_">\</a> SaveHistoriesAsync(string, History\[], RequestOptions)

Replaces the existing history-list for the currently logged in user. All elements must belong to the same history list. If not they are ignored.

```csharp theme={null}
Task<History[]> SaveHistoriesAsync(string historyName, History[] history, RequestOptions requestOptions = null)
```

#### Parameters

`historyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

`history` [History](SuperOffice.WebApi.Data.History.md)\[]

Array of new history items to save.

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[History](SuperOffice.WebApi.Data.History.md)\[]\&gt;

Array of the saved History items

### \<a id="SuperOffice\_WebApi\_Agents\_IViewStateAgent\_SetHistoryLengthPrefValueAsync\_System\_Int32\_SuperOffice\_WebApi\_RequestOptions\_">\</a> SetHistoryLengthPrefValueAsync(int, RequestOptions)

Set the logged on user's preferred history list length.

```csharp theme={null}
Task SetHistoryLengthPrefValueAsync(int length, RequestOptions requestOptions = null)
```

#### Parameters

`length` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The new history list lenght

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task)


## Related topics

- [SuperOffice.WebApi.Agents.ViewStateAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ViewStateAgent.md)
- [SuperOffice.WebApi.Agents.DiagnosticsAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.DiagnosticsAgent.md)
- [SuperOffice.WebApi.Agents.IDiagnosticsAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.IDiagnosticsAgent.md)
- [Upsert Recent Navigation](/en/api/reference/restful/agent/viewstate_agent/upsert-recent-navigation.md)
- [Get Histories By Names And Ids](/en/api/reference/restful/agent/viewstate_agent/get-histories-by-names-and-ids.md)
- [Save Currents](/en/api/reference/restful/agent/viewstate_agent/save-currents.md)
