Workflow Customization: General Information
In this chapter, you will learn how to modify an existing screen configuration and customize a predefined workflow by using Workflow API.
Learning Objectives
In this chapter, you will learn how to do the following:
- Customize an existing workflow
- Add a new action to the workflow
- Define a new category in the workflow
Applicable Scenarios
You customize an existing workflow when you need to modify a workflow defined for an MYOB Acumatica form.
Customization of Existing Workflows
By using Workflow API, you can not only create your own workflows but also customize workflows defined in the source code of MYOB Acumatica. Workflow API provides a set of methods to update and remove workflows and elements of a workflow, such as states and transitions.
To define a new workflow and screen configuration, you use the AddScreenConfigurationFor and AddDefaultFlow methods to add a workflow to a form, and Add methods to add actions, states, transitions, and other elements of the screen configuration to the workflow. For each of these Add methods, Workflow API provides the Update method for updating the element and the Delete method for deleting the element from the workflow. Similarly, for the AddScreenConfigurationFor and AddDefaultFlow methods, Workflow API provides the UpdateScreenConfigurationFor and UpdateDefaultFlow methods, which allow you to update the existing screen configuration and the existing default workflow, respectively. To access the elements of the screen configuration, you use the same methods as the methods that you use while adding the workflow, such as WithFlowStates, WithActions, and WithTransitions.
An example of an updated workflow is shown in the following code.
context.UpdateScreenConfigurationFor(screen =>
{
return screen
.UpdateDefaultFlow(InjectApprovalWorkflow)
.WithActions(actions =>
{
actions.Add(approve);
actions.Add(reject);
actions.Update(
g => g.putOnHold,
a => a.WithFieldAssignments(fas =>
{
fas.Add<ARRegister.approved>(f => f.SetFromValue(false));
fas.Add<ARRegister.rejected>(f => f.SetFromValue(false));
}));
actions.Update(
g => g.releaseFromCreditHold,
a => (BoundedTo<ARInvoiceEntry, ARInvoice>.
ActionDefinition.ConfiguratorAction)a.InFolder(approvalCategory, reject));
});
});