Workflow Identifying Fields: General Information
You can add multiple workflows for a particular form. In this case, 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.
For example, for sales orders on the Sales Orders (SO301000) form, one workflow can be applied to sales orders of a particular order type, such as SO, and another workflow can be applied to sales quotes, which have the QT order type.
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.
Defining 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 the 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>();
});
Defining a Workflow for the Specific Value of the Workflow-Identifying Field
To define a workflow for the specific value of the workflow-identifying field, do the following:
- Inside the AddScreenConfigurationFor or UpdateScreenConfigurationFor method, call the WithFlows method
- In the WithFlows method, 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, define states and transitions of the workflow 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 =>
{
...
}));
}));
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 using the AddDefaultFlow method. For details, see Step 3: Overriding the Configure Method.
- The set of workflows which are applied depending on the value of the workflow-identifying
fieldNote: If you haven't defined workflows for each value of the workflow-identifying field, the system applies the default workflow.