Step 1: Adding and Configuring the Action

In this step, you will add the Complete action in a graph and in the screen configuration. You will specify the location of the associated command by using the WithCategory method and assign the DAC field values by using the WithFieldAssignments method.

Do the following:

  1. In the RSSVWorkOrderEntry graph, declare the Complete action, as the following code shows.
            public PXAction<RSSVWorkOrder> Complete;
            [PXButton]
            [PXUIField(DisplayName = "Complete", Enabled = false)]
            protected virtual IEnumerable complete(PXAdapter adapter) => adapter.Get();
  2. In the RSSVWorkOrderWorkflow class, add the Complete action in the lambda expression for the WithActions method, as the following code shows.
                        actions.Add(g => g.Complete, c => c
                          .WithCategory(processingCategory, Placement.Last)
                          .WithFieldAssignments(fas => fas
                            .Add<RSSVWorkOrder.dateCompleted>(f =>
                              f.SetFromToday())));

    In the code above, you have defined the Complete action. In the WithCategory method, you have specified that the associated command will be displayed last in the Processing category of the More menu by specifying the Placement.Last parameter. Also, in the WithFieldAssignments method, by calling the SetFromToday method, you have specified that the RSSVWorkOrder.dateCompleted field is assigned the current business date.

  3. To make the Complete action available in the Assigned state, add the action to the configuration of the Assigned state in the WithFlowStates method, as the following code shows.
                            fss.Add<States.assigned>(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());
                                    })
                                    // Add the action to the configuration
                                    // of the Assigned state
                                    .WithActions(actions =>
                                    {
                                        actions.Add(g => g.Complete, a => a
                                          .IsDuplicatedInToolbar()
                                          .WithConnotation(ActionConnotation.Success));
                                    });
                            });