Filtering Parameters: To Add a Filter for an Inquiry Form

The following activity will walk you through the process of implementing custom filtering parameters for an inquiry form.

Story

Suppose that you need to add custom filtering parameters to the Open Payment Summary (RS401000) inquiry form, which you created in the PhoneRepairShop customization project, so that users can filter the repair work orders listed in the table on the inquiry form.

The form will contain filtering UI elements in the Selection area, which can be used to filter the list of repair work orders by the customer and service type, and to filter the list of sales orders by the customer. You will define filtering parameters for these UI elements.

Process Overview

In this activity, you will add filtering parameters to the Open Payment Summary (RS401000) inquiry form by performing the following steps:
  1. Defining the DAC with only unbound fields that will be used as filtering parameters
  2. Configuring the PXFilter data view and the PXCancel action as graph members used for filtering data for an inquiry form
  3. Adding the Selection area to the ASPX page of the inquiry form by using the px:PXFormView container control and configuring the filtering elements

System Preparation

Before you begin performing the steps of this activity, do the following:

  1. Configure your instance by performing the Test Instance for Customization: To Deploy an Instance for Developing Inquiry Forms prerequisite activity.
  2. Complete the steps described in the Inquiry Forms: To Set Up an Inquiry Form prerequisite activity.

Step 1: Defining a DAC with Filtering Parameters for the Inquiry Form

In this step, you will define the RSSVWorkOrderToPayFilter DAC, which will be used to display the selection criteria (filtering parameters) on the Open Payment Summary (RS401000) form. The DAC will contain two fields (CustomerID and ServiceID) that correspond to the filtering parameters. To define the DAC with filtering parameters, do the following:

  1. In the RSSVPaymentPlanInq graph, define the RSSVWorkOrderToPayFilter data access class by using the following code.
        [PXHidden]
        public class RSSVWorkOrderToPayFilter : PXBqlTable, IBqlTable
        {
            #region ServiceID
            [PXInt()]
            [PXUIField(DisplayName = "Service")]
            [PXSelector(
                typeof(Search<RSSVRepairService.serviceID>),
                typeof(RSSVRepairService.serviceCD),
                typeof(RSSVRepairService.description),
                DescriptionField = typeof(RSSVRepairService.description),
                SelectorMode = PXSelectorMode.DisplayModeText)]
            public virtual int? ServiceID { get; set; }
            public abstract class serviceID :
                PX.Data.BQL.BqlInt.Field<serviceID>
            { }
            #endregion
    
            #region CustomerID
            [CustomerActive(DisplayName = "Customer ID")]
            public virtual int? CustomerID { get; set; }
            public abstract class customerID :
                PX.Data.BQL.BqlInt.Field<customerID>
            { }
            #endregion
        }
  2. For the filtering parameters to be used in a BQL query, add the serviceID and customerID fields to the RSSVWorkOrderToPay DAC by using the following code.
            public new abstract class serviceID :
                PX.Data.BQL.BqlInt.Field<serviceID>
            { }
    
            public new abstract class customerID :
                PX.Data.BQL.BqlInt.Field<customerID>
            { }
    Tip:
    If you have generated the RSSVPaymentPlanInq graph by using the Screen Editor, in this step, you can also remove the MasterView data view because the RS401000.aspx file has no more references to the MasterView data view. You have removed those references with the Content element in Step 4: Configuring the ASPX Page of the Form of the Inquiry Forms: To Set Up an Inquiry Form activity. You can also remove the Save and Cancel actions, which were generated automatically.
  3. Build the project.

Step 2: Configuring the Graph Members Used for Filtering Data on the Inquiry Form

In this step, you will prepare the graph members that are used for filtering data on the form. To define the graph members, in the RSSVPaymentPlanInq graph, do the following:

  1. Define a PXFilter data view (as shown in the following code), which provides filtering parameters for the inquiry form.
            public PXFilter<RSSVWorkOrderToPayFilter> Filter;
  2. Define the PXCancel action, which adds the Cancel button to the form toolbar, as shown in the following code. The action clears the filter.
            public PXCancel<RSSVWorkOrderToPayFilter> Cancel;
  3. Replace the definition of the DetailsView data view with the following code, which not only selects repair work orders that do not have the Paid status but also matches the filtering criteria based on the values of the serviceID and customerID fields.
            [PXFilterable]
            public SelectFrom<RSSVWorkOrderToPay>.
                InnerJoin<ARInvoice>.On<ARInvoice.refNbr.IsEqual<
                    RSSVWorkOrderToPay.invoiceNbr>>.
                Where<RSSVWorkOrderToPay.status.IsNotEqual<
                    RSSVWorkOrderWorkflow.States.paid>.
                    And<RSSVWorkOrderToPayFilter.customerID.FromCurrent.IsNull.
                        Or<RSSVWorkOrderToPay.customerID.IsEqual<
                            RSSVWorkOrderToPayFilter.customerID.FromCurrent>>>.
                    And<RSSVWorkOrderToPayFilter.serviceID.FromCurrent.IsNull.
                        Or<RSSVWorkOrderToPay.serviceID.IsEqual<
                            RSSVWorkOrderToPayFilter.serviceID.FromCurrent>>>>.
                View.ReadOnly DetailsView;
  4. Override the IsDirty property of the graph, as the following code shows.
            public override bool IsDirty => false;
  5. Build the project.

Step 3: Adjusting the ASPX Page to Add Filtering Elements for the Inquiry Form

In this step, you will add the Selection area, which has the elements to be used for filtering, to the RS401000.aspx page. To make this addition to the ASPX page, do the following:

  1. Open the RS401000.aspx file.
  2. In the PrimaryView property of the PXDataSource control, specify the Filter data view, as shown in the following code.
      <px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
            TypeName="PhoneRepairShop.RSSVPaymentPlanInq"
            PrimaryView="Filter"
            >
  3. Add the following code to define the Selection area of the form.
    Tip:
    You can define the Selection area of the form in the Screen Editor without entering the code manually.
    <asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
      <px:PXFormView runat="server" ID="CstFormView1" DataSourceID="ds" 
          DataMember="Filter" Width="100%" >
        <Template>
          <px:PXLayoutRule LabelsWidth="XM" runat="server" ID="CstPXLayoutRule3" 
            StartColumn="True" ></px:PXLayoutRule>
          <px:PXSegmentMask CommitChanges="True" runat="server" ID="CstPXSegmentMask1" 
            DataField="CustomerID" ></px:PXSegmentMask>
          <px:PXSelector CommitChanges="True" runat="server" ID="CstPXSelector2" 
            DataField="ServiceID" ></px:PXSelector>
        </Template>
      </px:PXFormView>
    </asp:Content>

    The Selection area is defined by the PXFormView container control. For the DataMember property of the PXFormView control, you specify the Filter view. Inside the PXFormView control, you add a PXSegmentMask control to select a customer, and a PXSelector object to select a service.

  4. Save your changes.