Step 1: Adding the OrderType Field and Corresponding Box to the UI
To add multiple workflows to a form, you need to define a workflow-identifying field, which will hold a value that defines a particular workflow to be used for a record. In this step, you will add the workflow-identifying field to the Repair Work Orders (RS301000) form.
Do the following:
- Add the
UsrOrderType
field to theRSSVWorkOrder
database table by doing the following:- In the Customization Project Editor, open the Database Scripts page.
- On the More menu, click Add Custom Column to Table.
- In the Add Custom Column to Table dialog box
which opens, specify the following values:
- Table: RSSVWorkOrder
- Field Name:
UsrOrderTypeTip:The field must have the
Usr
prefix because it is a custom field. - Data Type: string
- Length: 2
- Click OK.
- Publish the customization project to apply the database script.
- In the Constants.cs file, add the list of possible values
for the
UsrOrderType
field as shown in the following code.//Constants for the repair work order types public static class WorkOrderTypeConstants { public const string Simple = "SP"; public const string Standard = "ST"; public const string Awaiting = "AW"; }
- In the Messages.cs file, add the list of UI string values
corresponding to the added constant strings as shown in the following
code.
//Work order types public const string Simple = "Simple"; public const string Standard = "Standard"; public const string Awaiting = "Awaiting Delivery";
- Create an extension of the
RSSVWorkOrder
DAC and add theUsrOrderType
field to theRSSVWorkOrder
DAC by using the following code.public sealed class RSSVWorkOrder_Extension : PXCacheExtension<RSSVWorkOrder> { #region Status [PXDBString(2, IsFixed = true)] [PXDefault(WorkOrderTypeConstants.Standard, PersistingCheck = PXPersistingCheck.Nothing)] [PXUIField(DisplayName = "Order Type")] [PXStringList( new string[] { WorkOrderTypeConstants.Simple, WorkOrderTypeConstants.Standard, WorkOrderTypeConstants.Awaiting }, new string[] { Messages.Simple, Messages.Standard, Messages.Awaiting })] public string? UsrOrderType { get; set; } public abstract class usrOrderType : PX.Data.BQL.BqlString.Field<usrOrderType> { } #endregion }
Tip:Use Acuminator to suppress the PX1016 error in a comment. In this course, for simplicity, the extension is always active. - Rebuild the
PhoneRepairShop_Code
project. - Add the Order Type box to the Repair Work Orders
(RS301000) form by doing the following:
- In the Customization Project Editor, open page.
- In the control tree, select the first column in the Form: WorkOrders node.
- On the Add Data Fields tab, select the
UsrOrderType
field and click Create Controls.The Order Type field appears as the first element of the selected column in the control tree.
- On the Layout Properties tab, for the
CommitChanges property, select
True.
Once a new value is selected in the box, the system will apply the workflow that corresponds to the selected value.
- Save your changes and publish the customization project.
- Open the Repair Work Orders (RS301000) form and make sure the Order Type box is displayed in the Summary area of the form as a drop down control.