# Class WorkflowCommand OptimaJet.Workflow.Core.Runtime.WorkflowCommand Represents a workflow command for use in an application. Namespace: [OptimaJet.Workflow.Core.Runtime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/) ```csharp public sealed class WorkflowCommand ``` ## Properties `public Guid ProcessId { get; set; }` Gets or sets the process identifier for which the command is valid. `public string ValidForActivityName { get; set; }` Gets or sets the activity name for which the command is valid. `public string ValidForStateName { get; set; }` Gets or sets the state name for which the command is valid. `public TransitionClassifier Classifier { get; set; }` Gets or sets the transition classifier for the command. [TransitionClassifier](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionClassifier/) `public bool IsForSubprocess { get; set; }` Gets or sets a value indicating whether the command was received from a subprocess. `public IEnumerable Identities { get; }` Gets the workflow participant identities that can execute the command. `public string CommandName { get; set; }` Gets or sets the system name of the command. `public string LocalizedName { get; set; }` Gets or sets the localized name of the command. ## Methods `public object GetParameter(string name)` Gets the value of the parameter with the specified name. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name. | ### Returns | Type | Description | | --- | --- | | `Object` | The parameter value, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no matching parameter exists. | `public void SetParameter(string name, object value, bool persist = false)` Sets a parameter value. Adds the parameter if it does not already exist. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name. | | `value` | `Object` | The parameter value. | | `persist` | `Boolean` | Whether the parameter is persistent. | `public static WorkflowCommand Create(Guid processId, TransitionDefinition transitionDefinition, ProcessDefinition processDefinition, Func deserializer = null, CultureInfo culture = null)` Creates a new [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) from a command transition. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The process identifier. | | `transitionDefinition` | `TransitionDefinition` | The command transition definition. | | `processDefinition` | `ProcessDefinition` | The parsed process definition used to resolve localized command and parameter names. | | `deserializer` | `Func` | An optional function used to deserialize parameter default values. | | `culture` | `CultureInfo` | The culture used to localize command and command parameter names. | ### Returns | Type | Description | | --- | --- | | `WorkflowCommand` | A populated [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) instance. | ### Exceptions | Type | Description | | --- | --- | | `InvalidOperationException` | Thrown if the transition is not a command transition or its command is missing. | `public void AddIdentity(string identityId)` Adds a workflow participant identity to the command's [WorkflowCommand.Identities](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) collection. ### Parameters | Name | Type | Description | | --- | --- | --- | | `identityId` | `String` | The workflow participant identity to add. | `public bool Validate(out string errorMessage)` Validates command data and parameter values. ### Parameters | Name | Type | Description | | --- | --- | --- | | `errorMessage` | `String` | When validation fails, contains a summary of validation errors. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the command is valid; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public void SetAllParametersToDefault()` Sets all parameter values to their default values. `public void SetParameterToDefault(string name)` Sets the value of the parameter with the specified name to its default value. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name. | ### Exceptions | Type | Description | | --- | --- | | `InvalidOperationException` | Thrown when no parameter with the specified name exists. | ## Fields `public List Parameters` Gets or sets the list of parameters for the command. [Previous UserIdentity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/UserIdentity/) [Next WorkflowErrorEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowErrorEventArgs/)