Workflow States: To Define a Workflow State
The following activity will walk you through the process of defining a state.
Story
Suppose that on the Repair Work Orders (RS301000) form, you need to add the On Hold and Ready for Assignment states to the workflow. The On Hold state should be the initial state of the workflow.
Process Overview
To define the states, in the Configure method of the
RSSVWorkOrderWorkflow
class, you will сall the
WithFlowStates method in the lambda expression specified for
the AddDefaultFlow method and provide the set of states in the
parameter. You will define each state by calling the Add method
and specifying the state identifier string as a generic parameter. As a parameter of
the Add method, you will specify a lambda expression where you
can configure the state.
System Preparation
In an instance with the T100 dataset, make sure that you have done the following:
- Prepared an instance with the PhoneRepairShop customization project and enabled the workflow validation by performing the prerequisite activities in the Preparing an Instance for Workflow Customization chapter.
- Prepared the screen configuration and defined the set of states by performing the prerequisite activities in the Preparing a Screen Configuration chapter.
Step: Defining the On Hold and Ready for Assignment States
To add the OnHold
and ReadyForAssignment
states, do
the following:
- In the
RSSVWorkOrderWorkflow
class, in theConfigure
method, locate theAddDefaultFlow
method. (You have added this method in Step 3: Overriding the Configure Method.) - Call the
WithFlowStates
method, as the following code shows..AddDefaultFlow(flow => flow .WithFlowStates(fss => { }))
- Inside the lambda expression of the WithFlowStates method,
add the
OnHold
state by calling the Add method, as the following code shows.fss.Add<States.onHold>(flowState => { return flowState .IsInitial() .WithActions(actions => { actions.Add(g => g.ReleaseFromHold, a => a .IsDuplicatedInToolbar() .WithConnotation(ActionConnotation.Success)); }); });
In the code above, you have added the
OnHold
state by specifying theStates.onHold
value as the generic parameter of the Add method. In the lambda expression passed to the Add method, you have done the following:- Specified that the
OnHold
state is the initial state of the workflow by calling the IsInitial method. - Specified the actions that are available in the
OnHold
state by calling the WithActions method and adding the action definition in the lambda expression. In this case, the ReleaseFromHold action is available in theOnHold
state. By calling the IsDuplicatedInToolbar method, you have specified that the action should be shown as a button on the toolbar for this state. - Specified the Success connotation for the action by calling the WithConnotation method. The button corresponding to this action will be highlighted in green when it is displayed on the form toolbar. For details, see Action Customization: Connotation for an Action.
- Specified that the
- After the
OnHold
state, define theReadyForAssignment
state, as the following code shows.fss.Add<States.readyForAssignment>(flowState => { return flowState .WithFieldStates(states => { states.AddField<RSSVWorkOrder.customerID>(state => state.IsDisabled()); states.AddField<RSSVWorkOrder.serviceID>(state => state.IsDisabled()); states.AddField<RSSVWorkOrder.deviceID>(state => state.IsDisabled()); }); ; });
In the code above, you have added the
ReadyForAssignment
state by specifying the States.readyForAssignment value as the generic parameter of the Add method. By calling the WithFieldStates method, you have specified the states of DAC fields in this states. In this case, you have specified that thecustomerID
,serviceID
, anddeviceID
fields of theRSSVWorkOrder
DAC should be disabled in this state. - Save your changes.