diff --git a/10/umbraco-forms/developer/extending/adding-a-workflowtype.md b/10/umbraco-forms/developer/extending/adding-a-workflowtype.md index 154c085719d..66dbf8b680b 100644 --- a/10/umbraco-forms/developer/extending/adding-a-workflowtype.md +++ b/10/umbraco-forms/developer/extending/adding-a-workflowtype.md @@ -1,8 +1,12 @@ # Adding a workflow type to Umbraco Forms -*This builds on the "[adding a type to the provider model](adding-a-type.md)" chapter* +*This builds on the "[Adding a type to the provider model](adding-a-type.md)" article.* -Add a new class to your project and have it inherit from `Umbraco.Forms.Core.WorkflowType`, implement the class. For this sample we will focus on the execute method. This method process the current record (the data submitted by the form) and have the ability to change data and state. +You can create a custom workflow type by inheriting from `Umbraco.Forms.Core.WorkflowType` and implementing the required methods. For this example, the focus is on the `Execute()` method. This method process the current record (the data submitted by the form) and allows you to modify data and state. + +## Creating a Custom Workflow + +Add a new class to your project: ```csharp using Serilog; @@ -64,11 +68,23 @@ namespace MyFormsExtensions } ``` -## Information available to the workflow +### Controlling Workflow Execution + +{% hint style="info" %} + +All workflows configured for a stage (submission or approval) will execute regardless of whether earlier workflows fail or set the record state to `Rejected`. + +However, setting `context.Record.State = FormState.Rejected` during a stage will prevent workflows in the **next** stage from executing. For example, if a submission workflow sets the state to `Rejected`, all approval workflows will be skipped. + +{% endhint %} + +To conditionally skip a specific workflow, add the conditional logic directly inside the workflow's `ExecuteAsync()` method. + +## Information Available to the Workflow -### Record information +### Record Information -The `Execute()` method gets a `WorkflowExecutionContext` which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. +The `Execute()` method receives a `WorkflowExecutionContext` object, which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. The `Record` contains all data and metadata submitted by the form. As shown in the example above, you can iterate over all `RecordField` values in the form. You can also retrieve a specific record field by alias using the following method: @@ -90,15 +106,15 @@ If the field stores multiple values, they are delimited with a comma. In many ca IEnumerable selectedPrevalues = recordField.GetSelectedPrevalues(); ``` -### Form and state information +### Form and State Information The `Form` references the form the record is from and `FormState` provides its state (submitted or approved). Other context, such as the current `HttpContext`, if needed can be passed as constructor parameters (for example: the `HttpContext` can be accessed by injecting `IHttpContextAccessor`). -## Registering the workflow type +## Registering the Workflow Type -To use the new workflow type, you will need to register it as part of application startup. +To use your custom workflow type, register it at application startup: ```csharp using Umbraco.Cms.Core.Composing; diff --git a/13/umbraco-forms/developer/extending/adding-a-workflowtype.md b/13/umbraco-forms/developer/extending/adding-a-workflowtype.md index 019f24f030d..77096306c8b 100644 --- a/13/umbraco-forms/developer/extending/adding-a-workflowtype.md +++ b/13/umbraco-forms/developer/extending/adding-a-workflowtype.md @@ -1,8 +1,12 @@ -# Adding a workflow type to Umbraco Forms +# Adding a Workflow Type to Umbraco Forms -*This builds on the "[adding a type to the provider model](adding-a-type.md)" chapter* +*This builds on the "[Adding a Type to the Provider Model](adding-a-type.md)" article.* -Add a new class to your project and have it inherit from `Umbraco.Forms.Core.WorkflowType`, and implement the class. For this sample, we will focus on the execute method. This method processes the current record (the data submitted by the form) and have the ability to change data and state. +You can create a custom workflow type by inheriting from `Umbraco.Forms.Core.WorkflowType` and implementing the required methods. For this example, the focus is on the `ExecuteAsync()` method. This method processes the current record (the data submitted by the form) and allows you to modify data and state. + +## Creating a Custom Workflow + +Add a new class to your project: ```csharp using Serilog; @@ -64,11 +68,23 @@ namespace MyFormsExtensions } ``` -## Information available to the workflow +### Controlling Workflow Execution + +{% hint style="info" %} + +All workflows configured for a stage (submission or approval) will execute regardless of whether earlier workflows fail or set the record state to `Rejected`. + +However, setting `context.Record.State = FormState.Rejected` during a stage will prevent workflows in the **next** stage from executing. For example, if a submission workflow sets the state to `Rejected`, all approval workflows will be skipped. + +{% endhint %} + +To conditionally skip a specific workflow, add the conditional logic directly inside the workflow's `ExecuteAsync()` method. + +## Information Available to the Workflow -### Record information +### Record Information -The `ExecuteAsync()` method gets a `WorkflowExecutionContext` which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. +The `ExecuteAsync()` method receives a `WorkflowExecutionContext` object, which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. The `Record` contains all data and metadata submitted by the form. As shown in the example above, you can iterate over all `RecordField` values in the form. You can also retrieve a specific record field by alias using the following method: @@ -90,15 +106,15 @@ If the field stores multiple values, they are delimited with a comma. In many ca IEnumerable selectedPrevalues = recordField.GetSelectedPrevalues(); ``` -### Form and state information +### Form and State Information The `Form` references the form the record is from and `FormState` provides its state (submitted or approved). Other context, such as the current `HttpContext`, if needed can be passed as constructor parameters (for example: the `HttpContext` can be accessed by injecting `IHttpContextAccessor`). -## Registering the workflow type +## Registering the Workflow Type -To use the new workflow type, you will need to register it as part of application startup. +To use your custom workflow type, register it at application startup: ```csharp using Umbraco.Cms.Core.Composing; diff --git a/15/umbraco-forms/developer/extending/adding-a-workflowtype.md b/15/umbraco-forms/developer/extending/adding-a-workflowtype.md index 019f24f030d..77096306c8b 100644 --- a/15/umbraco-forms/developer/extending/adding-a-workflowtype.md +++ b/15/umbraco-forms/developer/extending/adding-a-workflowtype.md @@ -1,8 +1,12 @@ -# Adding a workflow type to Umbraco Forms +# Adding a Workflow Type to Umbraco Forms -*This builds on the "[adding a type to the provider model](adding-a-type.md)" chapter* +*This builds on the "[Adding a Type to the Provider Model](adding-a-type.md)" article.* -Add a new class to your project and have it inherit from `Umbraco.Forms.Core.WorkflowType`, and implement the class. For this sample, we will focus on the execute method. This method processes the current record (the data submitted by the form) and have the ability to change data and state. +You can create a custom workflow type by inheriting from `Umbraco.Forms.Core.WorkflowType` and implementing the required methods. For this example, the focus is on the `ExecuteAsync()` method. This method processes the current record (the data submitted by the form) and allows you to modify data and state. + +## Creating a Custom Workflow + +Add a new class to your project: ```csharp using Serilog; @@ -64,11 +68,23 @@ namespace MyFormsExtensions } ``` -## Information available to the workflow +### Controlling Workflow Execution + +{% hint style="info" %} + +All workflows configured for a stage (submission or approval) will execute regardless of whether earlier workflows fail or set the record state to `Rejected`. + +However, setting `context.Record.State = FormState.Rejected` during a stage will prevent workflows in the **next** stage from executing. For example, if a submission workflow sets the state to `Rejected`, all approval workflows will be skipped. + +{% endhint %} + +To conditionally skip a specific workflow, add the conditional logic directly inside the workflow's `ExecuteAsync()` method. + +## Information Available to the Workflow -### Record information +### Record Information -The `ExecuteAsync()` method gets a `WorkflowExecutionContext` which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. +The `ExecuteAsync()` method receives a `WorkflowExecutionContext` object, which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. The `Record` contains all data and metadata submitted by the form. As shown in the example above, you can iterate over all `RecordField` values in the form. You can also retrieve a specific record field by alias using the following method: @@ -90,15 +106,15 @@ If the field stores multiple values, they are delimited with a comma. In many ca IEnumerable selectedPrevalues = recordField.GetSelectedPrevalues(); ``` -### Form and state information +### Form and State Information The `Form` references the form the record is from and `FormState` provides its state (submitted or approved). Other context, such as the current `HttpContext`, if needed can be passed as constructor parameters (for example: the `HttpContext` can be accessed by injecting `IHttpContextAccessor`). -## Registering the workflow type +## Registering the Workflow Type -To use the new workflow type, you will need to register it as part of application startup. +To use your custom workflow type, register it at application startup: ```csharp using Umbraco.Cms.Core.Composing; diff --git a/16/umbraco-forms/developer/extending/adding-a-workflowtype.md b/16/umbraco-forms/developer/extending/adding-a-workflowtype.md index 019f24f030d..77096306c8b 100644 --- a/16/umbraco-forms/developer/extending/adding-a-workflowtype.md +++ b/16/umbraco-forms/developer/extending/adding-a-workflowtype.md @@ -1,8 +1,12 @@ -# Adding a workflow type to Umbraco Forms +# Adding a Workflow Type to Umbraco Forms -*This builds on the "[adding a type to the provider model](adding-a-type.md)" chapter* +*This builds on the "[Adding a Type to the Provider Model](adding-a-type.md)" article.* -Add a new class to your project and have it inherit from `Umbraco.Forms.Core.WorkflowType`, and implement the class. For this sample, we will focus on the execute method. This method processes the current record (the data submitted by the form) and have the ability to change data and state. +You can create a custom workflow type by inheriting from `Umbraco.Forms.Core.WorkflowType` and implementing the required methods. For this example, the focus is on the `ExecuteAsync()` method. This method processes the current record (the data submitted by the form) and allows you to modify data and state. + +## Creating a Custom Workflow + +Add a new class to your project: ```csharp using Serilog; @@ -64,11 +68,23 @@ namespace MyFormsExtensions } ``` -## Information available to the workflow +### Controlling Workflow Execution + +{% hint style="info" %} + +All workflows configured for a stage (submission or approval) will execute regardless of whether earlier workflows fail or set the record state to `Rejected`. + +However, setting `context.Record.State = FormState.Rejected` during a stage will prevent workflows in the **next** stage from executing. For example, if a submission workflow sets the state to `Rejected`, all approval workflows will be skipped. + +{% endhint %} + +To conditionally skip a specific workflow, add the conditional logic directly inside the workflow's `ExecuteAsync()` method. + +## Information Available to the Workflow -### Record information +### Record Information -The `ExecuteAsync()` method gets a `WorkflowExecutionContext` which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. +The `ExecuteAsync()` method receives a `WorkflowExecutionContext` object, which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. The `Record` contains all data and metadata submitted by the form. As shown in the example above, you can iterate over all `RecordField` values in the form. You can also retrieve a specific record field by alias using the following method: @@ -90,15 +106,15 @@ If the field stores multiple values, they are delimited with a comma. In many ca IEnumerable selectedPrevalues = recordField.GetSelectedPrevalues(); ``` -### Form and state information +### Form and State Information The `Form` references the form the record is from and `FormState` provides its state (submitted or approved). Other context, such as the current `HttpContext`, if needed can be passed as constructor parameters (for example: the `HttpContext` can be accessed by injecting `IHttpContextAccessor`). -## Registering the workflow type +## Registering the Workflow Type -To use the new workflow type, you will need to register it as part of application startup. +To use your custom workflow type, register it at application startup: ```csharp using Umbraco.Cms.Core.Composing; diff --git a/17/umbraco-forms/developer/extending/adding-a-workflowtype.md b/17/umbraco-forms/developer/extending/adding-a-workflowtype.md index 019f24f030d..116c3f53332 100644 --- a/17/umbraco-forms/developer/extending/adding-a-workflowtype.md +++ b/17/umbraco-forms/developer/extending/adding-a-workflowtype.md @@ -1,8 +1,12 @@ -# Adding a workflow type to Umbraco Forms +# Adding a Workflow Type to Umbraco Forms -*This builds on the "[adding a type to the provider model](adding-a-type.md)" chapter* +*This builds on the "[Adding a Type to the Provider Model](adding-a-type.md)" article.* -Add a new class to your project and have it inherit from `Umbraco.Forms.Core.WorkflowType`, and implement the class. For this sample, we will focus on the execute method. This method processes the current record (the data submitted by the form) and have the ability to change data and state. +You can create a custom workflow type by inheriting from `Umbraco.Forms.Core.WorkflowType` and implementing the required methods. For this example, the focus is on the `ExecuteAsync()` method. This method processes the current record (the data submitted by the form) and allows you to modify data and state. + +## Creating a Custom Workflow + +Add a new class to your project: ```csharp using Serilog; @@ -64,11 +68,23 @@ namespace MyFormsExtensions } ``` -## Information available to the workflow +### Controlling Workflow Execution + +{% hint style="info" %} + +All workflows configured for a stage (submission or approval) will execute regardless of whether earlier workflows fail or set the record state to `Rejected`. + +However, setting `context.Record.State = FormState.Rejected` during a stage will prevent workflows in the **next** stage from executing. For example, if a submission workflow sets the state to `Rejected`, all approval workflows will be skipped. + +{% endhint %} + +To conditionally skip a specific workflow, add the conditional logic directly inside the workflow's `ExecuteAsync()` method. + +## Information Available to the Workflow -### Record information +### Record Information -The `ExecuteAsync()` method gets a `WorkflowExecutionContext` which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. +The `ExecuteAsync()` method receives a `WorkflowExecutionContext` object, which has properties for the related `Form`, `Record`, and `FormState`. This parameter contains all information related to the workflow. The `Record` contains all data and metadata submitted by the form. As shown in the example above, you can iterate over all `RecordField` values in the form. You can also retrieve a specific record field by alias using the following method: @@ -90,7 +106,7 @@ If the field stores multiple values, they are delimited with a comma. In many ca IEnumerable selectedPrevalues = recordField.GetSelectedPrevalues(); ``` -### Form and state information +### Form and State Information The `Form` references the form the record is from and `FormState` provides its state (submitted or approved). @@ -98,7 +114,7 @@ Other context, such as the current `HttpContext`, if needed can be passed as con ## Registering the workflow type -To use the new workflow type, you will need to register it as part of application startup. +To use your custom workflow type, register it at application startup: ```csharp using Umbraco.Cms.Core.Composing;