Step 6: Add the Transition

Without a composite state, you would need to remove or modify an existing transition and add at least two transitions instead: one to the new state, and another from the new state. But with a composite state, you need to add only one transition: from the Postponed nested state to the next nested state of the composite state.

To add a transition from the Postponed state to the next state in the composite state, do the following:

  1. In the UpdateDefaultFlow method, add the following code.
    .WithTransitions(transitions =>
    {
        transitions.AddGroupFrom<ARDocStatus_Postponed.postponed>(ts =>
        {
            ts.Add(t => t
                .ToNext()
                .IsTriggeredOn(approveDiscount)
                .WithFieldAssignments(fass => 
                    fass.Add<ARInvoice.discDate>(f => f.SetFromToday())));
        });
    });

    In the code above, you have added a transition group where the initial state is the Postponed state. In the transition group, you have done the following:

    • Added the transition to the next state in the composite state by calling the ToNext method
    • Specified an action that triggered the transition in the IsTriggeredOn method
    • Used the WithFieldAssigments method to specify that the Cash Discount Date box should be assigned the current date when the transition is performed
  2. Save your changes.