# Interface IFormDataProvider OptimaJet.Workflow.Core.Persistence.IFormDataProvider Defines persistence operations for retrieving, creating, versioning, updating, and deleting [WorkflowForm](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/WorkflowForm/) instances. Namespace: [OptimaJet.Workflow.Core.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/) ```csharp public interface IFormDataProvider ``` ## Type Hierarchy - IFormDataProvider Current type - Derived interfaces - [IPersistenceProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/IPersistenceProvider/) - [IWorkflowProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/IWorkflowProvider/) - Implementing types - [MongoDBProvider](https://api.workflowengine.io/mongodb/OptimaJet.Workflow.MongoDB/MongoDBProvider/) - [MSSQLProvider](https://api.workflowengine.io/sql-server/OptimaJet.Workflow.DbPersistence/MSSQLProvider/) - [FileSchemePersistenceMSSQLProvider](https://api.workflowengine.io/sql-server/OptimaJet.Workflow.DbPersistence/FileSchemePersistenceMSSQLProvider/) - [MySQLProvider](https://api.workflowengine.io/mysql/OptimaJet.Workflow.MySQL/MySQLProvider/) - [OracleProvider](https://api.workflowengine.io/oracle/OptimaJet.Workflow.Oracle/OracleProvider/) - [FileSchemePersistenceOracleProvider](https://api.workflowengine.io/oracle/OptimaJet.Workflow.Oracle/FileSchemePersistenceOracleProvider/) - [PostgreSQLProvider](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/PostgreSQLProvider/) - [FileSchemePersistencePostgreSQLProvider](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/FileSchemePersistencePostgreSQLProvider/) - [SqliteProvider](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/SqliteProvider/) - [FileSchemePersistenceSqliteProvider](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/FileSchemePersistenceSqliteProvider/) ## Methods `Task GetFormAsync(string name, int? version = null, string? tenantId = null)` Gets a form by name and optional version. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The form name. | | `version` | `Nullable` | The form version, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to retrieve the latest available version. | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to read from the shared scope. When specified, latest-version reads prefer the tenant scope and use the shared scope only when the tenant scope contains no forms with the specified name. Version-specific reads use the shared scope only when the tenant scope contains no versions of the form. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result contains the matching [WorkflowForm](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/WorkflowForm/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when no matching form is found. | `Task> GetFormNamesAsync(string? tenantId = null)` Gets the distinct form names available in the selected scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to read from the shared scope. When specified, the result combines names from the tenant and shared scopes. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result contains the distinct form names available in the selected scope. | `Task> GetFormVersionsAsync(string name, string? tenantId = null)` Gets the distinct versions of a form available in the selected scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The form name. | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to read from the shared scope. When specified, the result contains tenant-scoped versions when the tenant scope contains the form; otherwise it contains shared versions. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result contains the distinct form version numbers available in the selected scope. | `Task CreateNewFormVersionAsync(string name, string defaultDefinition, int? version = null, string? tenantId = null)` Creates a new version of a form in the selected scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The form name. | | `defaultDefinition` | `String` | The form definition to use when `version` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) and no source form is available in the target scope or, when initializing a tenant scope, the shared scope. | | `version` | `Nullable` | The source form version whose definition is copied, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use the latest source form. A specified version must exist in the target scope, or in the shared scope when initializing an empty tenant scope. | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to create the version in the shared scope. When creating the first version in a tenant scope, the definition may be copied from the shared scope. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result contains the newly created [WorkflowForm](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/WorkflowForm/). | `Task CreateNewFormIfNotExistsAsync(string name, string defaultDefinition, string? tenantId = null)` Gets the latest form in the selected scope, or creates version 0 when the scope contains no form with the specified name. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The form name. | | `defaultDefinition` | `String` | The definition to use for a newly created form when no shared form is available as a source. | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use the shared scope. A new tenant-scoped form uses the shared form definition when one is available. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result contains the existing or newly created [WorkflowForm](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/WorkflowForm/). | `Task UpdateFormAsync(string name, int version, int lockValue, string definition, string? tenantId = null)` Updates a form version's definition using optimistic concurrency. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The form name. | | `version` | `Int32` | The form version to update. | | `lockValue` | `Int32` | The expected current lock value for optimistic concurrency. | | `definition` | `String` | The new form definition. | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to update the shared scope. The update is limited to the selected scope. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result contains the new lock value. | `Task DeleteFormVersionAsync(string name, int version, string? tenantId = null)` Deletes a specific version of a form from the selected scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The form name. | | `version` | `Int32` | The form version to delete. | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to delete from the shared scope. The deletion is limited to the selected scope. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | `Task DeleteFormAsync(string name, string? tenantId = null)` Deletes all versions of a form from the selected scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The form name. | | `tenantId` | `String` | The tenant identifier, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to delete from the shared scope. The deletion is limited to the selected scope. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | [Previous IApprovalProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/IApprovalProvider/) [Next InboxItem](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/InboxItem/)