Screen Configuration: To Prepare a Screen Configuration with a Predefined Workflow
Most data entry forms of MYOB Acumatica have at least one predefined workflow—that is, a workflow that is implemented in the original code of MYOB Acumatica.
The following activity will walk you through the process of performing the initial steps for customizing a predefined workflow.
Learning Objectives
In this chapter, you will learn how to do the following:
- Locate a class where the predefined workflow is implemented
- Create a graph extension where a customized workflow can be implemented
- Override the Configure method
Story
Suppose that you need to define a workflow for the Invoices (SO303000) form, which has a predefined workflow—that is, a workflow that has been implemented by MYOB developers.
Process Overview
To extend the predefined workflow of the Invoices (SO303000) form, in the source code of MYOB Acumatica, you will first find the class where the workflow is defined. You will then create an extension of this class and prepare the method where you can later customize the workflow.
System Preparation
As a prerequisite activity, perform the activities of the Preparing an Instance for Workflow Customization chapter to configure your instance.
Make sure you have enabled the workflow validation as described in Test Instance for Workflow Customization: To Enable Workflow Validation.
Step 1: Locating the Class that Defines the Workflow
To locate the class where the workflow is defined, you should look into the PX.Objects/<area> folder in the source code of MYOB Acumatica, where <area> is the code of the functional area of the form for which the workflow is defined. In most cases, workflows of this functional area are located in the Workflows folder of this location. Sometimes all workflow classes are located at the same level as the graph classes—that is, in the PX.Objects/<area> folder.
To locate the class where the workflow for the Invoices (SO303000) form is defined, do the following:
- In the source code of MYOB Acumatica, locate the PX.Objects/SO/Workflow folder.
- In this folder, find the SOInvoiceEntry_Workflow class, which
is an extension of the SOInvoiceEntry graph.
In the code of the SOInvoiceEntry_Workflow class, notice that the states of the workflow are defined in the ARDocStatus class. You will need this class if you want to use the states of the workflow in your code.
Step 2: Extending the Predefined Workflow
To extend a predefined workflow, you need to create an extension of the class where the workflow is defined. In this extension, you need to override the Configure(PXScreenConfiguration) method, which initializes the screen configuration.
To extend a predefined workflow, do the following:
- In the Workflows folder of the
PhoneRepairShop_Code
project, create the SOInvoiceRepairOrder_Workflow.cs file. - In the SOInvoiceRepairOrder_Workflow.cs file, define the
SOInvoiceRepairOrder_Workflow
class, as the following code shows.public class SOInvoiceOrder_Workflow : PXGraphExtension<SOInvoiceEntry_Workflow, SOInvoiceEntry> { public sealed override void Configure(PXScreenConfiguration config) { Configure(config.GetScreenConfigurationContext<SOInvoiceEntry, ARInvoice>()); } protected static void Configure(WorkflowContext<SOInvoiceEntry, ARInvoice> context) { } }
In the code above, you have defined an extension of the SOInvoiceEntry_Workflow class. As a second parameter of the extension, you have specified the graph of the Invoices form. In the extension, you have overridden the Configure(PXScreenConfiguration) method, which initializes the screen configuration, and have declared the Configure(WorkflowContext) method, where you can later update the workflow.
- Make sure that you have added the needed
using
directives. - Save your changes.