Workflow-Identifying Fields: General Information
You can add multiple workflows for a particular form so that each workflow is applied to all records that have a specific value in a particular field. This field is described as a workflow-identifying field because its value determines the workflow to be used.
Learning Objectives
In this chapter, you will gain experience creating a workflow that is based on the specific value of a selected field.
Applicable Scenarios
You customize a workflow with a workflow-identifying field if you need to make changes to the workflow so that it is better suited for your business processes, and you do not want to create such a workflow from scratch.
Workflow Types
A form can have the following types of workflows:
- The default workflow
The form can have only one default workflow, which is defined with the AddDefaultFlow method. For details, see Screen Configuration: To Prepare a Screen Configuration for a Form Without a Predefined Workflow.
- A set of workflows, which are applied depending on the value of the workflow-identifying
fieldAttention:If you have not defined a workflow for a value of the workflow-identifying field, the system applies the default workflow for a record if this value is selected for the record.
Definition of a Workflow-Identifying Field
You define a workflow-identifying field by specifying it in the screen configuration.
To specify a workflow-identifying field, you call the FlowTypeIdentifierIs method in the lambda expression for the AddScreenConfigurationFor or UpdateScreenConfigurationFor method and specify a string field from the primary DAC of the form as the type parameter. An example is shown in the following code.
context.AddScreenConfigurationFor(screen =>
{
return screen
.StateIdentifierIs<status>()
.FlowTypeIdentifierIs<SOOrder.behavior>();
});
Definition of a Workflow for the Specific Value of the Workflow-Identifying Field
To define a workflow for the specific value of the workflow-identifying field, you do the following:
- Inside the AddScreenConfigurationFor or UpdateScreenConfigurationFor method, you call the WithFlows method.
- In the WithFlows method, you call the Add method.
As the type parameter of the Add method, you specify the value of the workflow-identifying field.
- Inside the Add method, you define workflow states and transitions, as described in Defining Workflow States and Implementing Transitions.
An example of the workflow for the specific value of the workflow-identifying field is shown in the following code.
context.UpdateScreenConfigurationFor(screen => screen
.WithFlows(flows =>
{
flows.Add<SOBehavior.bL>(flow => flow
.WithFlowStates(flowStates =>
{
...
}
.WithTransitions(transitions =>
{
...
}));
}));