# Class ProcessInstance OptimaJet.Workflow.Core.Model.ProcessInstance Represents one execution of a scheme, with its own current activity, business state, and process parameters. Namespace: [OptimaJet.Workflow.Core.Model](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/) ```csharp public sealed class ProcessInstance ``` ## Properties `public Guid ProcessId { get; set; }` Gets or sets the identifier of this process instance. `public Guid? ParentProcessId { get; set; }` Gets or sets the identifier of the immediate parent process instance, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for a top-level process instance. `public Guid RootProcessId { get; set; }` Gets or sets the identifier of the top-level root process instance in the process hierarchy. `public Guid SchemeId { get; set; }` Gets or sets the identifier of the built process scheme version used by this process instance. `public string PreviousState { get; set; }` Gets or sets the business state from [TransitionDefinition.From](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) for the most recently executed transition whose source activity has a nonempty [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). `public string ExecutedTimer { get; set; }` Gets or sets the name of the [TimerDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TimerDefinition/) that initiated the current transition execution. `public string PreviousStateForDirect { get; set; }` Gets or sets the business state from [TransitionDefinition.From](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) for the most recently executed [TransitionClassifier.Direct](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionClassifier/) transition whose source activity has a nonempty [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). `public string PreviousStateForReverse { get; set; }` Gets or sets the business state from [TransitionDefinition.From](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) for the most recently executed [TransitionClassifier.Reverse](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionClassifier/) transition whose source activity has a nonempty [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). `public string PreviousActivityName { get; set; }` Gets or sets the source activity name for the most recently executed transition. `public string PreviousActivityForDirectName { get; set; }` Gets or sets the source activity name for the most recently executed [TransitionClassifier.Direct](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionClassifier/) transition. `public string PreviousActivityForReverseName { get; set; }` Gets or sets the source activity name for the most recently executed [TransitionClassifier.Reverse](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionClassifier/) transition. `public string CurrentCommand { get; set; }` Gets or sets the name of the applicable [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) for the current execution. `public string IdentityId { get; set; }` Gets or sets the workflow participant identity of the executor that initiates the current execution. `public string ImpersonatedIdentityId { get; set; }` Gets or sets the workflow participant identity on whose behalf the current execution is performed. `public string ExecutedActivityState { get; set; }` Gets or sets the business state used while [ProcessInstance.ExecutedActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) is executing. When the activity has no [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/), Workflow Engine uses [ProcessInstance.CurrentState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). `public ActivityDefinition ExecutedActivity { get; set; }` Gets or sets the [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) being executed. `public TransitionDefinition ExecutedTransition { get; set; }` Gets or sets the [TransitionDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) being executed. `public string CurrentActivityName { get; set; }` Gets or sets the name of the current [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). `public List IdentityIds { get; set; }` Gets or sets the workflow participant identities resolved for transitions leading to activities along the path currently explored by pre-execution simulation. This value is populated only when [ProcessInstance.IsPreExecution](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). `public List IdentityIdsForCurrentActivity { get; set; }` Gets or sets the workflow participant identities that can execute a transition from the current activity. Unlike [ProcessInstance.IdentityIds](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/), this property applies only to the current activity rather than the entire simulated path. This value is populated only when [ProcessInstance.IsPreExecution](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). `public string SchemeCode { get; set; }` Gets or sets the code of the process scheme used by this process instance. `public string CurrentState { get; set; }` Gets or sets the current business state name of this process instance. `public string TenantId { get; }` Gets the tenant identifier assigned to the process instance. `public string StartTransitionalProcessActivity { get; set; }` Gets or sets the name of the activity from which transitional execution started. When no value is stored, the getter returns [ProcessInstance.CurrentActivityName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). `public ActivityDefinition CurrentActivity { get; }` Gets the [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) in [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) identified by [ProcessInstance.CurrentActivityName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). ### Exceptions | Type | Description | | --- | --- | | `ActivityNotFoundException` | No activity in [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) is named [ProcessInstance.CurrentActivityName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | `public bool IsPreExecution { get; set; }` Gets or sets a value indicating whether the process instance is being evaluated in pre-execution simulation. `public string SubprocessName { get; set; }` Gets or sets the name assigned to this subprocess by the starting [TransitionDefinition.SubprocessName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/). `public DateTime CreationDate { get; set; }` Gets or sets the date and time when the process instance was created. `public DateTime? LastTransitionDate { get; set; }` Gets or sets the date and time of the most recent transition execution. `public DateTime? StartTransitionTime { get; set; }` Gets or sets the date and time when the current transition execution started. `public bool LogEnabled { get; set; }` Gets or sets a value indicating whether logging is enabled for this process instance. When no instance override exists, the getter returns [ProcessDefinition.LogEnabled](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) from [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). `public string ActionParameterBeforeSubstitution { get; set; }` Gets or sets the current action parameter before process parameter placeholders are substituted. `public string CalendarName { get; set; }` Gets or sets the work calendar name assigned to the process instance. `public IWorkflowExternalParametersProvider ExternalParametersProvider { get; }` Gets the [IWorkflowExternalParametersProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IWorkflowExternalParametersProvider/) configured for the associated [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). `public ProcessDefinition ProcessScheme { get; set; }` Gets or sets the built [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) associated with the process instance. `public bool IsSchemeObsolete { get; }` Gets a value indicating whether the associated process scheme version is obsolete. `public bool IsSubprocess { get; }` Gets a value indicating whether this process instance is a subprocess, as identified by a non-self [ProcessInstance.ParentProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). `public ParametersCollection ProcessParameters { get; }` Gets the [ParametersCollection](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParametersCollection/) owned by the process instance. `public ParametersCollection MergedSubprocessParameters { get; }` Gets the [ParametersCollection](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParametersCollection/) from a subprocess that was merged into the current process instance. `public dynamic this[string name, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary] { get; set; }` Gets or sets the value of a process parameter or nested parameter property. `public Localizer Localizer { get; }` Gets a [ProcessInstance.Localizer](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) that searches the localization sources from [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and the associated [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). ## Methods `public static ProcessInstance Create(WorkflowRuntime runtime, Guid schemeId, Guid processId, ProcessDefinition processScheme, bool isSchemeObsolete, string tenantId = null, string calendarName = null)` Creates a process instance for `processScheme` and associates it with `runtime`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) that owns the process instance. | | `schemeId` | `Guid` | The identifier of the built process scheme version to assign to [ProcessInstance.SchemeId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `processId` | `Guid` | The identifier to assign to [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `processScheme` | `ProcessDefinition` | The built [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) to assign to [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `isSchemeObsolete` | `Boolean` | The value to assign to [ProcessInstance.IsSchemeObsolete](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `tenantId` | `String` | The tenant identifier to assign to [ProcessInstance.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). A [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), empty, or white-space value is stored as [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | | `calendarName` | `String` | The work calendar name to assign to [ProcessInstance.CalendarName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `ProcessInstance` | The created [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Exceptions | Type | Description | | --- | --- | | `LicenseException` | The number of activities, transitions, or commands in `processScheme` exceeds the applicable license limit. | `public string GetSchemeCodeForActionCall()` Gets the process scheme code used when invoking code actions. ### Returns | Type | Description | | --- | --- | | `String` | [ProcessDefinition.RootSchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) when [ProcessDefinition.IsSubprocessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and the root scheme code is not empty; otherwise, the name of [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | `public void Save(WorkflowRuntime runtime)` Saves parameters whose [ParameterDefinition.Purpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) by using `runtime`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) whose [WorkflowRuntime.PersistenceProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) performs the save. | `public Task SaveAsync(WorkflowRuntime runtime)` Asynchronously saves parameters whose [ParameterDefinition.Purpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) by using `runtime`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) whose [WorkflowRuntime.PersistenceProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) performs the save. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous save operation. | `public ICalendar GetCalendar()` Gets the work calendar selected for the process instance. ### Returns | Type | Description | | --- | --- | | `ICalendar` | The [ICalendar](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/ICalendar/) from [WorkflowRuntime.Calendars](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) selected by [ProcessInstance.CalendarName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/), [ProcessDefinition.CalendarName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/), or [WorkflowRuntime.DefaultCalendarName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/), in that order; or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no matching calendar is registered. | `public ProcessInstance Clone()` Creates a copy of this process instance with a cloned [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/), a recursively copied parent process hierarchy, and a separate [ProcessInstance.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) collection. ### Returns | Type | Description | | --- | --- | | `ProcessInstance` | The cloned [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | `public void AddParameter(ParameterDefinitionWithValue parameter)` Adds a parameter to [ProcessInstance.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/), replacing any existing entries with the same parameter name. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameter` | `ParameterDefinitionWithValue` | The [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) to add. | `public void AddParameters(IEnumerable parameters)` Adds parameters to [ProcessInstance.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/), replacing existing entries whose names match the names in `parameters`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `IEnumerable` | The [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) objects to add. | `public bool IsParameterExisting(string name)` Determines whether [ProcessInstance.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) contains a non-null parameter value or an existing nested parameter property identified by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the parameter has a non-null value or the nested property exists; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public ParameterDefinitionWithValue GetParameter(string name)` Gets the parameter or nested parameter property identified by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | ### Returns | Type | Description | | --- | --- | | `ParameterDefinitionWithValue` | The matching [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no parameter is found or a nested value is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public Task GetParameterAsync(string name)` Asynchronously gets the parameter or nested parameter property identified by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result is the matching [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no parameter is found or a nested value is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | ### Exceptions | Type | Description | | --- | --- | | `ArgumentException` | `name` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty. | `public T GetParameter(string name)` Gets the value of the parameter or nested parameter property identified by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | ### Returns | Type | Description | | --- | --- | | `{T}` | The value as `T`, or the default value of `T` if no value is found. | ### Example If the `Order` parameter contains a nested `Customer.Name` property, `processInstance.GetParameter("Order.Customer.Name")` returns that property's value. `public Task GetParameterAsync(string name)` Asynchronously gets the value of the parameter or nested parameter property identified by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result is the value as `T`, or the default value of `T` if no value is found. | ### Exceptions | Type | Description | | --- | --- | | `ArgumentException` | `name` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty. | ### Example If the `Order` parameter contains a nested `Customer.Name` property, `await processInstance.GetParameterAsync("Order.Customer.Name")` returns that property's value. `public void SetParameter(string name, T value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary)` Sets the value of the parameter or nested parameter property identified by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | | `value` | `{T}` | The value to assign. | | `purposeIfMissing` | `ParameterPurpose` | The [ParameterPurpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) to use when no definition exists in [ProcessDefinition.Parameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). When `purposeIfMissing` is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/), a scheme-defined parameter that is not yet instantiated is also created as persistent. | ### Example `processInstance.SetParameter("Order.Customer.Name", "Alice")` assigns `"Alice"` to the nested `Name` property of `Customer` in the `Order` parameter. `public Task SetParameterAsync(string name, T value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary)` Asynchronously sets the value of the parameter or nested parameter property identified by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | | `value` | `{T}` | The value to assign. | | `purposeIfMissing` | `ParameterPurpose` | The [ParameterPurpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) to use when no definition exists in [ProcessDefinition.Parameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). When `purposeIfMissing` is [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/), a scheme-defined parameter that is not yet instantiated is also created as persistent. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `ArgumentException` | `name` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty. | ### Example `await processInstance.SetParameterAsync("Order.Customer.Name", "Alice")` assigns `"Alice"` to the nested `Name` property of `Customer` in the `Order` parameter. `public void SetImplicitSerializedParameter(string name, string value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary)` Sets an implicit parameter from its JSON-serialized value. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The name of the implicit parameter. | | `value` | `String` | The JSON-serialized parameter value. | | `purposeIfMissing` | `ParameterPurpose` | The [ParameterPurpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) to assign if the implicit parameter must be created. | `public void RemoveParameter(string name)` Sets the value of a process parameter or nested parameter property to [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name or dot-separated path to a nested property. | `public void SetProcessParameters(List parameters)` Replaces the contents of [ProcessInstance.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) with `parameters`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `List` | The [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/) objects that become the collection contents. | `public void InitPersistenceParametersFromScheme()` Initializes parameters whose definitions in [ProcessDefinition.Parameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) have [ParameterDefinition.Purpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) set to [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) and whose [ParameterDefinition.InitialValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) is not [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). ### Exceptions | Type | Description | | --- | --- | | `InvalidJsonParameterValueException` | A persistence parameter other than [string](https://learn.microsoft.com/dotnet/api/system.string) has an initial value that cannot be deserialized from JSON. | `public bool ExecuteConditionFromCodeActions(string name, WorkflowRuntime runtime, string parameter)` Evaluates the condition named `name` in local or global code actions. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The name of the condition to evaluate. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) used to resolve and invoke the condition. | | `parameter` | `String` | The additional parameter passed to the condition. | ### Returns | Type | Description | | --- | --- | | `Boolean` | The condition result. | `public Task ExecuteConditionFromCodeActionsAsync(string name, WorkflowRuntime runtime, string parameter)` Asynchronously evaluates the condition named `name` in local or global code actions. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The name of the condition to evaluate. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) used to resolve and invoke the condition. | | `parameter` | `String` | The additional parameter passed to the condition. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result is the condition result. | ### Exceptions | Type | Description | | --- | --- | | `NotImplementedException` | No condition named `name` can be resolved. | `public void ExecuteCodeAction(string name, WorkflowRuntime runtime, string parameter)` Executes the action named `name` in local or global code actions. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The name of the action to execute. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) used to resolve and invoke the action. | | `parameter` | `String` | The additional parameter passed to the action. | `public Task ExecuteCodeActionAsync(string name, WorkflowRuntime runtime, string parameter)` Asynchronously executes the action named `name` in local or global code actions. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The name of the action to execute. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) used to resolve and invoke the action. | | `parameter` | `String` | The additional parameter passed to the action. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `NotImplementedException` | No action named `name` can be resolved. | `public string GetLocalizedStateName(string name, CultureInfo culture = null)` Gets the localization for the business state named by `name`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The business state name used as the localization key. | | `culture` | `CultureInfo` | The culture to use, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). | ### Returns | Type | Description | | --- | --- | | `String` | The localized business state name if found; otherwise, `name`. | `public string GetLocalizedCommandName(string name, CultureInfo culture = null)` Gets the localization for `name` with [LocalizeType.Command](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/LocalizeType/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The command name used as the localization key. | | `culture` | `CultureInfo` | The culture to use, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). | ### Returns | Type | Description | | --- | --- | | `String` | The localized command name if found; otherwise, `name`. | `public string GetLocalizedParameterName(string name, CultureInfo culture = null)` Gets the localization for `name` with [LocalizeType.Parameter](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/LocalizeType/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The parameter name used as the localization key. | | `culture` | `CultureInfo` | The culture to use, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). | ### Returns | Type | Description | | --- | --- | | `String` | The localized parameter name if found; otherwise, `name`. | `public string GetLocalizedActionName(string name, CultureInfo culture = null)` Gets the localization for `name` with [LocalizeType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/LocalizeType/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The action name used as the localization key. | | `culture` | `CultureInfo` | The culture to use, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). | ### Returns | Type | Description | | --- | --- | | `String` | The localized action name if found; otherwise, `name`. | `public string GetLocalizedConditionName(string name, CultureInfo culture = null)` Gets the localization for `name` with [LocalizeType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/LocalizeType/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The condition name used as the localization key. | | `culture` | `CultureInfo` | The culture to use, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). | ### Returns | Type | Description | | --- | --- | | `String` | The localized condition name if found; otherwise, `name`. | `public string GetLocalizedSchemeName(CultureInfo culture = null)` Gets the localized name of [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) by using [LocalizeType.Scheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/LocalizeType/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `culture` | `CultureInfo` | The culture to use, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). | ### Returns | Type | Description | | --- | --- | | `String` | The localized process scheme name if found; otherwise, the original name of [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | `public string GetLocalizedComment(string key, CultureInfo culture = null)` Gets the localization for `key` with [LocalizeType.Comment](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/LocalizeType/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `key` | `String` | The comment key to localize. | | `culture` | `CultureInfo` | The culture to use, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to use [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). | ### Returns | Type | Description | | --- | --- | | `String` | The localized comment if found; otherwise, `key`. | `public string ProcessParametersToString(ParameterPurpose purpose)` Formats process parameters whose [ParameterDefinition.Purpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinition/) equals `purpose` as text. ### Parameters | Name | Type | Description | | --- | --- | --- | | `purpose` | `ParameterPurpose` | The [ParameterPurpose](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) to include. | ### Returns | Type | Description | | --- | --- | | `String` | Text containing one `name='value'` line for each matching parameter, ordered by parameter name. | `public void SetActivityAfterActionExecution(string activityName)` Schedules the activity named `activityName` to be set and executed immediately after the current action finishes. ### Parameters | Name | Type | Description | | --- | --- | --- | | `activityName` | `String` | The name of the activity to set and execute. | ### Exceptions | Type | Description | | --- | --- | | `ActivityNotFoundException` | No activity in [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) is named `activityName`. | `public void SetActivityAfterActivityExecution(string activityName)` Schedules the activity named `activityName` to be set and executed after the current activity finishes executing all of its actions. ### Parameters | Name | Type | Description | | --- | --- | --- | | `activityName` | `String` | The name of the activity to set and execute. | ### Exceptions | Type | Description | | --- | --- | | `ActivityNotFoundException` | No activity in [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) is named `activityName`. | `public void SetStateAfterActionExecution(string stateName)` Schedules the activity associated with the business state named `stateName` to be set and executed immediately after the current action finishes. ### Parameters | Name | Type | Description | | --- | --- | --- | | `stateName` | `String` | The business state name used to select the activity. | ### Exceptions | Type | Description | | --- | --- | | `ActivityNotFoundException` | No activity in [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) has a nonempty [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) equal to `stateName` and [ActivityDefinition.IsForSetState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) set to [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public void SetStateAfterActivityExecution(string stateName)` Schedules the activity associated with the business state named `stateName` to be set and executed after the current activity finishes executing all of its actions. ### Parameters | Name | Type | Description | | --- | --- | --- | | `stateName` | `String` | The business state name used to select the activity. | ### Exceptions | Type | Description | | --- | --- | | `ActivityNotFoundException` | No activity in [ProcessInstance.ProcessScheme](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) has a nonempty [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) equal to `stateName` and [ActivityDefinition.IsForSetState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) set to [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public string SubstituteValue(string parameter)` Replaces process parameter placeholders in `parameter`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameter` | `String` | The text to inspect for process parameter placeholders. | ### Returns | Type | Description | | --- | --- | | `String` | The text with matching placeholders replaced, or `parameter` if no placeholders match. | `public Task SubstituteValueAsync(string parameter)` Asynchronously replaces process parameter placeholders in `parameter`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameter` | `String` | The text to inspect for process parameter placeholders. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result is the text with matching placeholders replaced, or `parameter` if no placeholders match. | `public T GetRootPersistedParameter(string parameterName)` Gets the value of the parameter named `parameterName` from the root process instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | ### Returns | Type | Description | | --- | --- | | `{T}` | The parameter value as `T`, or the default value of `T` if no value is found. | `public Task GetRootPersistedParameterAsync(string parameterName)` Asynchronously gets the value of the parameter named `parameterName` from the root process instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result is the parameter value as `T`, or the default value of `T` if no value is found. | `public ParameterDefinitionWithValue GetRootPersistedParameter(string parameterName)` Gets the parameter named `parameterName` from the root process instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | ### Returns | Type | Description | | --- | --- | | `ParameterDefinitionWithValue` | The matching [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no parameter is found. | `public Task GetRootPersistedParameterAsync(string parameterName)` Asynchronously gets the parameter named `parameterName` from the root process instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1) whose result is the matching [ParameterDefinitionWithValue](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterDefinitionWithValue/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if no parameter is found. | `public void SetRootPersistenceParameter(string parameterName, T value)` Sets `parameterName` on the root process instance, creating the parameter with [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) when it is missing. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | | `value` | `{T}` | The value to assign. | `public Task SetRootPersistenceParameterAsync(string parameterName, T value)` Asynchronously sets `parameterName` on the root process instance, creating the parameter with [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) when it is missing. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | | `value` | `{T}` | The value to assign. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `ImpossibleToSetStatusException` | The root process could not be locked for the update. | `public void RemoveRootPersistenceParameter(string parameterName)` Clears the parameter named `parameterName` in the root process instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | `public Task RemoveRootPersistenceParameterAsync(string parameterName)` Asynchronously clears the parameter named `parameterName` in the root process instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameterName` | `String` | The parameter name. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `ImpossibleToSetStatusException` | The root process could not be locked for the update. | [Previous ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) [Next ProcessInstanceTenantGlobalParameterExtensions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstanceTenantGlobalParameterExtensions/)