Step 1: Add the OrderType Field and Corresponding Box to the UI

In order to add multiple workflows to a form, you need to have a field which will hold a value depending on which a workflow is applied (workflow-identifying field). In this step, you will add the workflow-identifying field to the form.

You can use any string field of the primary DAC as a workflow-identifying field.

Note: This step uses modified instruction for adding a custom field to a form which you can see in a greater detail in Step 1: Creating a Custom Field.

Do the following:

  1. Add the UsrOrderType field to the RSSVWorkOrder database table by doing the following:
    1. In the Customization Project Editor, open the Database Scripts page.
    2. In the page menu, click Add Custom Column to Table.
    3. In the Add Custom Column to Table dialog box which opens, specify the following values:
      • Table: RSSVWorkOrder
      • Field Name: UsrOrderType
        Note: The field must have the Usr prefix because it is a custom field.
      • Data Type: string
      • Length: 2
    4. Click OK.
    5. Publish the customization project to apply the database script.
  2. 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";
        }
  3. 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";
  4. Create an extension of the RSSVWorkOrder DAC and add the UsrOrderType field to the RSSVWorkOrder 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
      }
    Note: Use Acuminator to suppress the PX1016 error in a comment. In this course, for simplicity, the extension is always active.
  5. Add the Order Type box to the Repair Work Orders (RS301000) form by doing the following:
    1. Build your customization project.
    2. In the Customization Project Editor, open Screens > RS301000 page.
    3. In the control tree, select the first column in the Form: WorkOrders node.
    4. 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.

    5. On the Layout Properties tab, for the CommitChanges property, select True.

      This will allow to apply another workflow once the new value is selected in the box.

    6. Save your changes and publish the customization project.
    7. 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.