Step 1: Adding a Condition Pack
To implement a transition from the OnHold
state to the
ReadyForAssignment
or PendingPayment
state, based on the
properties of the current repair work order, you need to define two conditions: one that is
true when a repair work order requires prepayment, and another that is true when it does not
require prepayment. You will declare these conditions in this step. Each condition will be
checked in the corresponding transition.
A repair work order requires prepayment when the service specified for the order requires
prepayment. The service requires prepayment if the Prepayment check
box is selected for the service on the Repair Services (RS201000) form. This means that to
check whether a repair work order requires prepayment, you need to check the value of the
prepayment
property of the RSSVRepairService
DAC record,
which has the same serviceID
value as the repair work order.
To declare the conditions, do the following:
- In the
RSSVWorkOrderWorkflow
class, add theConditions
region. - In the
Conditions
region, declare a condition pack, as the following code shows.public class Conditions : Condition.Pack { }
- In the
Conditions
class, declare a condition that is true when the repair work order requires prepayment, as the following code shows.public Condition RequiresPrepayment => GetOrCreate(b => b.FromBql< Where<Selector<RSSVWorkOrder.serviceID, RSSVRepairService.prepayment>, Equal<True>>>());
In the code above, you have created a condition by calling the GetOrCreate method and provided a BQL statement in the lambda expression. In the BQL statement, you have selected the
RSSVRepairService
record by using theRSSVWorkOrder.serviceID
value and checked whether theRSSVRepairService.prepayment
value equals true. - After the
RequiresPrepayment
condition, declare a condition that is true when the repair work order does not require prepayment, as the following code shows.public Condition DoesNotRequirePrepayment => GetOrCreate(b => b.FromBql< Where<Selector<RSSVWorkOrder.serviceID, RSSVRepairService.prepayment>, Equal<False>>>());
In the code above, you have created the same condition as the previous one, except that you have checked whether the
RSSVRepairService.prepayment
value equals false. - In the Configure method, create an instance of the
Conditions class, as the following code
shows.
protected static void Configure(WorkflowContext<RSSVWorkOrderEntry, RSSVWorkOrder> context) { // Create an instance of the Conditions class var conditions = context.Conditions.GetPack<Conditions>(); ... }
- Save your changes.