# Class WorkflowForm OptimaJet.Workflow.SQLite.Models.WorkflowForm Database object for workflow form storage and versioning operations. Namespace: [OptimaJet.Workflow.SQLite.Models](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite.Models/) ```csharp public class WorkflowForm : DbObject ``` ## Type Hierarchy - [DbObject](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/DbObject-TEntity/) - WorkflowForm Current type ## Constructors `public WorkflowForm(string schemaName, int commandTimeout)` Initializes a new instance of [WorkflowForm](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite.Models/WorkflowForm/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemaName` | `String` | The database schema name. | | `commandTimeout` | `Int32` | The command timeout in seconds. | ## Methods `public Task> GetFormNamesAsync(SqliteConnection connection, string tenantId = null)` Gets the distinct list of form names accessible in the specified tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms only. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of form names. | `public Task GetFormAsync(SqliteConnection connection, string name, int? version = null, string tenantId = null)` Gets a form entity by name and optional version within the specified tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `name` | `String` | The form name. | | `version` | `Nullable` | The form version, or `null` to get the latest version. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms. | ### Returns | Type | Description | | --- | --- | | `Task` | The form entity if found; otherwise, `null`. | `public Task> GetFormVersionsAsync(SqliteConnection connection, string name, string tenantId = null)` Gets the list of distinct form versions for the specified form name within the tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `name` | `String` | The form name. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of version numbers. | `public Task CreateNewFormVersionAsync(SqliteConnection connection, DateTime creationDate, string name, string defaultDefinition, int? version = null, string tenantId = null)` Creates a new version of the form. If `version` is specified, copies the definition from that version; otherwise copies from the latest version. Falls back to the shared form if the tenant-scoped form is not found. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `creationDate` | `DateTime` | The creation date for the new version. | | `name` | `String` | The form name. | | `defaultDefinition` | `String` | The default definition to use if no source version is found. | | `version` | `Nullable` | The source version to copy from, or `null` to copy from the latest. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms. | ### Returns | Type | Description | | --- | --- | | `Task` | The newly created form entity, or `null` if the specified source version was not found. | `public Task CreateNewFormIfNotExistsAsync(SqliteConnection connection, DateTime creationDate, string name, string defaultDefinition, string tenantId = null)` Creates a new form with version 0 if a form with the specified name does not already exist in the given tenant scope. Falls back to the shared form definition if the tenant-scoped form is not found. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `creationDate` | `DateTime` | The creation date for the new form. | | `name` | `String` | The form name. | | `defaultDefinition` | `String` | The default definition to use if no shared form exists. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms. | ### Returns | Type | Description | | --- | --- | | `Task` | The existing or newly created form entity. | `public Task UpdateFormAsync(SqliteConnection connection, string name, int version, long oldLock, long newLock, string definition, DateTime updatedDate, string tenantId = null)` Updates the form definition with optimistic locking. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `name` | `String` | The form name. | | `version` | `Int32` | The form version to update. | | `oldLock` | `Int64` | The current lock value for optimistic concurrency. | | `newLock` | `Int64` | The new lock value to set. | | `definition` | `String` | The new form definition. | | `updatedDate` | `DateTime` | The update timestamp. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms. | ### Returns | Type | Description | | --- | --- | | `Task` | The new lock value if the update succeeded. | `public Task DeleteFormVersionAsync(SqliteConnection connection, string name, int version, string tenantId = null)` Deletes a specific version of the form within the specified tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `name` | `String` | The form name. | | `version` | `Int32` | The version to delete. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that represents the asynchronous operation. | `public Task DeleteFormAsync(SqliteConnection connection, string name, string tenantId = null)` Deletes all versions of the form within the specified tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `name` | `String` | The form name. | | `tenantId` | `String` | The tenant identifier, or `null` for shared forms. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that represents the asynchronous operation. | [Previous QueryDefinition](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite.Models/QueryDefinition/) [Next WorkflowRuntime](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite.Models/WorkflowRuntime/)