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:
- In the
RSSVWorkOrderEntry
graph, declare theComplete
action, as the following code shows.public PXAction<RSSVWorkOrder> Complete; [PXButton] [PXUIField(DisplayName = "Complete", Enabled = false)] protected virtual IEnumerable complete(PXAdapter adapter) => adapter.Get();
- In the
RSSVWorkOrderWorkflow
class, add theComplete
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 theRSSVWorkOrder.dateCompleted
field is assigned the current business date. - To make the
Complete
action available in theAssigned
state, add the action to the configuration of theAssigned
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)); }); });